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

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

public class PartialOrderOr<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 not previous filters passed.

Author:
b.elliottsmith

Constructor Summary
PartialOrderOr(FilterPartialOrder<P> a, FilterPartialOrder<P> b)
          Construct 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
<P> PartialOrderOr<P>
get(FilterPartialOrder<P> a, FilterPartialOrder<P> b)
          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

PartialOrderOr

public PartialOrderOr(FilterPartialOrder<P> a,
                      FilterPartialOrder<P> b)
Construct a new filter representing the disjunction (i.e. "or") of the supplied partial order filters.

Parameters:
a - filter to apply first
b - filter to apply second
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 <P> PartialOrderOr<P> get(FilterPartialOrder<P> a,
                                        FilterPartialOrder<P> b)
Returns the disjunction (i.e. "or") of the supplied partial order filters.

Parameters:
a - filter to apply first
b - filter to apply second
Returns:
disjunction (i.e. "or") of a and b