org.jjoost.util.filters
Class BothFilterMultiAnd<E,F extends Filter<? super E> & FilterPartialOrder<E>>

java.lang.Object
  extended by org.jjoost.util.filters.BothFilterMultiAnd<E,F>
All Implemented Interfaces:
java.io.Serializable, Filter<E>, FilterPartialOrder<E>, BothFilter<E>

public class BothFilterMultiAnd<E,F extends Filter<? super E> & FilterPartialOrder<E>>
extends java.lang.Object
implements BothFilter<E>

A filter representing the conjunction (i.e. "and") of the supplied filters implementing both Filter and FilterPartialOrder. The filters are evaluated in the order they are provided (left-to-right) and are evaluated if and only if all previous filters passed.

Author:
b.elliottsmith
See Also:
Serialized Form

Constructor Summary
BothFilterMultiAnd(F... filters)
          Construct a new filter representing the conjunction (i.e.
BothFilterMultiAnd(java.lang.Iterable<? extends F> filters)
          Construct a new filter representing the conjunction (i.e.
 
Method Summary
 boolean accept(E test)
          Returns true if the Filter accepts the parameter and false otherwise
 boolean accept(E test, java.util.Comparator<? super E> cmp)
          Return true iff this filter and comparator combination accept the provided value
static
<E,F extends Filter<? super E> & FilterPartialOrder<E>>
BothFilterMultiAnd<E,F>
get(F... filters)
          Returns the conjunction (i.e.
static
<E,F extends Filter<? super E> & FilterPartialOrder<E>>
BothFilterMultiAnd<E,F>
get(java.lang.Iterable<? extends F> filters)
          Returns the conjunction (i.e.
 boolean mayAcceptBetween(E lb, boolean lbInclusive, E ub, boolean ubInclusive, java.util.Comparator<? super E> cmp)
          Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may accept.
 boolean mayRejectBetween(E lb, boolean lbInclusive, E ub, boolean ubInclusive, java.util.Comparator<? super E> cmp)
          Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may reject.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BothFilterMultiAnd

public BothFilterMultiAnd(F... filters)
Construct a new filter representing the conjunction (i.e. "and") of the supplied filters

Parameters:
filters - filters to apply

BothFilterMultiAnd

public BothFilterMultiAnd(java.lang.Iterable<? extends F> filters)
Construct a new filter representing the conjunction (i.e. "and") of the supplied filters

Parameters:
filters - filters to apply
Method Detail

accept

public boolean accept(E test)
Description copied from interface: Filter
Returns true if the Filter accepts the parameter and false otherwise

Specified by:
accept in interface Filter<E>
Parameters:
test - value to test
Returns:
true if the filter accepts test; false otherwise

accept

public boolean accept(E test,
                      java.util.Comparator<? super E> cmp)
Description copied from interface: FilterPartialOrder
Return true iff this filter and comparator combination accept the provided value

Specified by:
accept in interface FilterPartialOrder<E>
Parameters:
test - the value to check
cmp - the partial order
Returns:
true, if accepts

mayAcceptBetween

public boolean mayAcceptBetween(E lb,
                                boolean lbInclusive,
                                E ub,
                                boolean ubInclusive,
                                java.util.Comparator<? super E> cmp)
Description copied from interface: FilterPartialOrder
Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may accept. This method may return true if there is no such value, at the cost of more expensive execution but valid behaviour, however it cannot return false if there is such a value without breaking functionality. null values should be seen as both +/- infinity, i.e. containsBetween(null, o) should return containsBefore(o) and containsBetween(o, null) should return containsAfter(o) containsBetween should take arguments IN ORDER, i.e. o1 <= o2; behaviour where o2 < o1 is undefined.

Specified by:
mayAcceptBetween in interface FilterPartialOrder<E>
Parameters:
lb - the lower bound of the range to check
lbInclusive - if the lower bound should be taken as inclusive
ub - the upper bound of the range to check
ubInclusive - if the upper bound should be taken as inclusive
cmp - the partial order
Returns:
true, if there may exists a value V such that lb <(/<=) V <(/<=) ub and accept(V, cmp) == true

mayRejectBetween

public boolean mayRejectBetween(E lb,
                                boolean lbInclusive,
                                E ub,
                                boolean ubInclusive,
                                java.util.Comparator<? super E> cmp)
Description copied from interface: FilterPartialOrder
Returns true if there exists (in the total order defined by the comparator, not necessarily in any concrete data set this is being applied to) a value between lb and ub that this filter may reject. This method may return true if there is no such value at the cost of more expensive execution but valid behaviour, however it cannot return false if there is such a value without breaking functionality. null values should be seen as both +/- infinity, i.e. containsBetween(null, o) should return containsBefore(o) and containsBetween(o, null) should return containsAfter(o) containsBetween should take arguments IN ORDER, i.e. o1 <= o2; behaviour where o2 < o1 is undefined.

Specified by:
mayRejectBetween in interface FilterPartialOrder<E>
Parameters:
lb - the lower bound of the range to check
lbInclusive - if the lower bound should be taken as inclusive
ub - the upper bound of the range to check
ubInclusive - if the upper bound should be taken as inclusive
cmp - the partial order
Returns:
true, if there may exists a value V such that lb <(/<=) V <(/<=) ub and accept(V, cmp) == false

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

get

public static <E,F extends Filter<? super E> & FilterPartialOrder<E>> BothFilterMultiAnd<E,F> get(F... filters)
Returns the conjunction (i.e. "and") of the supplied filters

Parameters:
filters - filters to apply
Returns:
conjunction (i.e. "and") of provided filters

get

public static <E,F extends Filter<? super E> & FilterPartialOrder<E>> BothFilterMultiAnd<E,F> get(java.lang.Iterable<? extends F> filters)
Returns the conjunction (i.e. "and") of the supplied filters

Parameters:
filters - filters to apply
Returns:
conjunction (i.e. "and") of provided filters