package org.xbib.logging.filters;

import java.util.logging.Filter;
import java.util.logging.LogRecord;

/**
 * An inverting filter.
 */
public final class InvertFilter implements Filter {
    private final Filter target;

    /**
     * Construct a new instance.
     *
     * @param target the target filter
     */
    public InvertFilter(final Filter target) {
        this.target = target;
    }

    /**
     * Determine whether a log record passes this filter.
     *
     * @param record the log record
     * @return {@code true} if the target filter returns {@code false}, {@code false} otherwise
     */
    @Override
    public boolean isLoggable(final LogRecord record) {
        return !target.isLoggable(record);
    }
}
