org.jjoost.util.filters
Class PartialOrderMultiOr<P>

java.lang.Object
  extended by org.jjoost.util.filters.PartialOrderMultiOr<P>
All Implemented Interfaces:
FilterPartialOrder<P>

public class PartialOrderMultiOr<P>
extends java.lang.Object
implements FilterPartialOrder<P>

A filter representing the disjunction (i.e. "or") of the supplied partial order filters. 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

Constructor Summary
PartialOrderMultiOr(FilterPartialOrder<P>... filters)
          Constructs a new filter representing the disjunction (i.e.
PartialOrderMultiOr(java.lang.Iterable<? extends FilterPartialOrder<P>> filters)
          Constructs a new filter representing the disjunction (i.e.
 
Method Summary
 boolean accept(P test, java.util.Comparator<? super P> cmp)
          Return true iff this filter and comparator combination accept the provided value
static
<E> PartialOrderMultiOr<E>
get(FilterPartialOrder<E>... filters)
          Returns the disjunction (i.e.
static
<E> PartialOrderMultiOr<E>
get(java.lang.Iterable<? extends FilterPartialOrder<E>> filters)
          Returns the disjunction (i.e.
 boolean mayAcceptBetween(P lb, boolean lbInclusive, P ub, boolean ubInclusive, java.util.Comparator<? super P> 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(P lb, boolean lbInclusive, P ub, boolean ubInclusive, java.util.Comparator<? super P> 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartialOrderMultiOr

public PartialOrderMultiOr(FilterPartialOrder<P>... filters)
Constructs a new filter representing the disjunction (i.e. "or") of the supplied partial order filters

Parameters:
filters - filters to apply

PartialOrderMultiOr

public PartialOrderMultiOr(java.lang.Iterable<? extends FilterPartialOrder<P>> filters)
Constructs a new filter representing the disjunction (i.e. "or") of the supplied partial order filters

Parameters:
filters - filters to apply
Method Detail

mayAcceptBetween

public boolean mayAcceptBetween(P lb,
                                boolean lbInclusive,
                                P ub,
                                boolean ubInclusive,
                                java.util.Comparator<? super P> 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<P>
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(P lb,
                                boolean lbInclusive,
                                P ub,
                                boolean ubInclusive,
                                java.util.Comparator<? super P> 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<P>
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

accept

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

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

get

public static <E> PartialOrderMultiOr<E> get(FilterPartialOrder<E>... filters)
Returns the disjunction (i.e. "or") of the supplied partial order filters

Parameters:
filters - filters to apply
Returns:
disjunction (i.e. "or") of provided filters

get

public static <E> PartialOrderMultiOr<E> get(java.lang.Iterable<? extends FilterPartialOrder<E>> filters)
Returns the disjunction (i.e. "or") of the supplied partial order filters

Parameters:
filters - filters to apply
Returns:
disjunction (i.e. "or") of provided filters