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

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

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

A that negates/inverts the results of the supplied filter. Users should be aware that filters that do not accurately implement mayAcceptBetween may break on negation.

Author:
b.elliottsmith

Constructor Summary
PartialOrderNot(FilterPartialOrder<P> negate)
          Construct a new filter which negates the results of the filter provided
 
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> PartialOrderNot<P>
get(FilterPartialOrder<P> negate)
          Returns the negation of the supplied partial order filter
 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

PartialOrderNot

public PartialOrderNot(FilterPartialOrder<P> negate)
Construct a new filter which negates the results of the filter provided

Parameters:
negate - filter to negate
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> PartialOrderNot<P> get(FilterPartialOrder<P> negate)
Returns the negation of the supplied partial order filter

Parameters:
negate - filter to negate
Returns:
negation of the supplied partial order filter