org.jjoost.util.filters
Class AcceptUniqueSequence<V>

java.lang.Object
  extended by org.jjoost.util.filters.AcceptUniqueSequence<V>
All Implemented Interfaces:
java.io.Serializable, Filter<V>

public class AcceptUniqueSequence<V>
extends java.lang.Object
implements Filter<V>

A Filter which returns true if and only if the previously tested value is not equal to the value being tested, using the provided definition of equality.

See Also:
Serialized Form

Constructor Summary
AcceptUniqueSequence()
          Construct a new Filter which returns true if and only if the previously tested value is not equal to the value being tested, using regular object equality.
AcceptUniqueSequence(Equality<? super V> eq)
          Construct a new Filter which returns true if and only if the previously tested value is not equal to the value being tested, using the provided definition of equality.
 
Method Summary
 boolean accept(V next)
          Returns true if the Filter accepts the parameter and false otherwise
static
<V> AcceptUniqueSequence<V>
get()
          Returns a Filter which returns true if and only if the previously tested value is not equal to the value being tested, using regular object equality.
static
<V> AcceptUniqueSequence<V>
get(Equality<? super V> eq)
          Returns a Filter which returns true if and only if the previously tested value is not equal to the value being tested, using the provided definition of equality.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AcceptUniqueSequence

public AcceptUniqueSequence()
Construct a new Filter which returns true if and only if the previously tested value is not equal to the value being tested, using regular object equality.


AcceptUniqueSequence

public AcceptUniqueSequence(Equality<? super V> eq)
Construct a new Filter which returns true if and only if the previously tested value is not equal to the value being tested, using the provided definition of equality.

Method Detail

accept

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

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

toString

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

get

public static <V> AcceptUniqueSequence<V> get()
Returns a Filter which returns true if and only if the previously tested value is not equal to the value being tested, using regular object equality.

Returns:
a filter rejecting any values equal to their predecessor

get

public static <V> AcceptUniqueSequence<V> get(Equality<? super V> eq)
Returns a Filter which returns true if and only if the previously tested value is not equal to the value being tested, using the provided definition of equality.

Returns:
a filter rejecting any values equal to their predecessor