package io.citrine.jcc.search.core.query;

import com.fasterxml.jackson.annotation.JsonSetter;

/**
 * Filter that can be applied to boolean-valued fields.
 * 
 * @author Kyle Michel
 */
public class BooleanFilter implements HasLogic {

    @Override
    public BooleanFilter setLogic(final Logic logic) {
        this.logic = logic;
        return this;
    }

    @Override
    public Logic getLogic() {
        return this.logic;
    }

    /**
     * Set whether to check for existence.
     *
     * @param exist True if the field must exist.
     */
    @JsonSetter
    private void setExist(final Boolean exist) {  // Private since only Jackson should use it
        this.setExists(exist);
    }

    /**
     * Set whether to check for existence.
     *
     * @param exists True if the field must exist.
     * @return This object.
     */
    public BooleanFilter setExists(final Boolean exists) {
        this.exists = exists;
        return this;
    }

    /**
     * Get whether to check for existence.
     *
     * @return True if the field must exist or a null pointer if it has not been set.
     */
    public Boolean getExists() {
        return this.exists;
    }

    /**
     * Set the state to match against.
     * 
     * @param equal Boolean value to match against.
     * @return This object.
     */
    public BooleanFilter setEqual(final Boolean equal) {
        this.equal = equal;
        return this;
    }

    /**
     * Get the boolean value to match against.
     *
     * @return Match state or a null pointer if it has not been set.
     */
    public Boolean getEqual() {
        return this.equal;
    }

    /** Logic for applying the filters. */
    private Logic logic;

    /** Just check for existence. */
    private Boolean exists;
    
    /** State to match against. */
    private Boolean equal;
}
@@ -80,22 +80,135 @@
 ion.Json
-Setter
+Ignore;%0Aimport com.fasterxml.jackson.annotation.JsonSetter;%0Aimport io.citrine.jcc.util.ListUtil;%0A%0Aimport java.util.List
 ;%0A%0A/**%0A 
@@ -1749,24 +1749,1938 @@
 ual;%0A    %7D%0A%0A
+    /**%0A     * Set the list of filters. This overrides any values that are already saved.%0A     *%0A     * @param filter List of %7B@link BooleanFilter%7D objects to save.%0A     * @return This object.%0A     */%0A    public BooleanFilter setFilter(final List%3CBooleanFilter%3E filter) %7B%0A        this.filter = filter;%0A        return this;%0A    %7D%0A%0A    /**%0A     * Add each in a list of filters.%0A     *%0A     * @param filter List of %7B@link BooleanFilter%7D objects to save.%0A     * @return This object.%0A     */%0A    @JsonIgnore%0A    public BooleanFilter addFilter(final List%3CBooleanFilter%3E filter) %7B%0A        this.filter = ListUtil.add(filter, this.filter);%0A        return this;%0A    %7D%0A%0A    /**%0A     * Add to the list of nested filter.%0A     *%0A     * @param filter %7B@link Filter%7D object to add.%0A     * @return This object.%0A     */%0A    @JsonIgnore%0A    public BooleanFilter addFilter(final BooleanFilter filter) %7B%0A        this.filter = ListUtil.add(filter, this.filter);%0A        return this;%0A    %7D%0A%0A    /**%0A     * Get the number of nested filters have been applied.%0A     *%0A     * @return Number of filters.%0A     */%0A    @JsonIgnore%0A    public int filterLength() %7B%0A        return ListUtil.length(this.filter);%0A    %7D%0A%0A    /**%0A     * Get an iterable over the list of nested filter.%0A     *%0A     * @return Iterable of %7B@link Filter%7D objects.%0A     */%0A    @JsonIgnore%0A    public Iterable%3CBooleanFilter%3E filter() %7B%0A        return ListUtil.iterable(this.filter);%0A    %7D%0A%0A    /**%0A     * Get a single filter.%0A     *%0A     * @param index Index of the filter to get.%0A     * @return Filter at the input index.%0A     */%0A    @JsonIgnore%0A    public BooleanFilter getFilter(final int index) %7B%0A        return ListUtil.get(this.filter, index);%0A    %7D%0A%0A    /**%0A     * Get the list of filters.%0A     *%0A     * @return List of %7B@link BooleanFilter%7D objects or a null pointer if not set.%0A     */%0A    public List%3CBooleanFilter%3E getFilter() %7B%0A        return this.filter;%0A    %7D%0A%0A
     /** Logi
@@ -3837,24 +3837,24 @@
 against. */%0A
-
     private 
@@ -3867,10 +3867,83 @@
 n equal;
+%0A%0A    /** List of sub-filters. */%0A    private List%3CBooleanFilter%3E filter;
 %0A%7D

add nested boolean filter