Top Description Fields Constructors Methods
org.apache.commons.collections4.functors

public final Class UniquePredicate<T>

extends Object
implements Predicate<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.collections4.Predicate
Imports
java.io.Serializable, java.util.HashSet, .Set, org.apache.commons.collections4.Predicate

Predicate implementation that returns true the first time an object is passed into the predicate.
Since
3.0

Field Summary

Modifier and TypeField and Description
private final Set<T>
iSet

The set of previously seen objects

private static final long
serialVersionUID

Serial version UID

Constructor Summary

AccessConstructor and Description
public
UniquePredicate()

Constructor that performs no validation.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this is the first time the object is seen
evaluate
(final T
the input object
object
)

Implements org.apache.commons.collections4.Predicate.evaluate.

Evaluates the predicate returning true if the input object hasn't been received yet.
public static <
the type that the predicate queries
T
>
Predicate<T>

Returns:

the predicate
uniquePredicate
()

Factory to create the predicate.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iSetback to summary
private final Set<T> iSet

The set of previously seen objects

serialVersionUIDback to summary
private static final long serialVersionUID

Serial version UID

Constructor Detail

UniquePredicateback to summary
public UniquePredicate()

Constructor that performs no validation. Use uniquePredicate if you want that.

Method Detail

evaluateback to summary
public boolean evaluate(final T object)

Implements org.apache.commons.collections4.Predicate.evaluate.

Evaluates the predicate returning true if the input object hasn't been received yet.

Parameters
object:T

the input object

Returns:boolean

true if this is the first time the object is seen

Annotations
@Override
uniquePredicateback to summary
public static <T> Predicate<T> uniquePredicate()

Factory to create the predicate.

Parameters
<T>
the type that the predicate queries
Returns:Predicate<T>

the predicate

Exceptions
IllegalArgumentException:
if the predicate is null