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

public final Class OnePredicate<T>

extends AbstractQuantifierPredicate<T>
Class Inheritance
Imports
java.util.Collection, org.apache.commons.collections4.Predicate

Predicate implementation that returns true if only one of the predicates return true. If the array of predicates is empty, then this predicate returns false.

Note

In versions prior to 3.2 an array size of zero or one threw an exception.

Since
3.0

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from org.apache.commons.collections4.functors.AbstractQuantifierPredicate:
iPredicates

Constructor Summary

AccessConstructor and Description
public
OnePredicate(final Predicate<? super T>...
the predicates to check, not cloned, not null
predicates
)

Constructor that performs no validation.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if only one decorated predicate returns true
evaluate
(final T
the input object
object
)

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

Evaluates the predicate returning true if only one decorated predicate returns true.
public static <
the type that the predicate queries
T
>
Predicate<T>

Returns:

the any predicate
onePredicate
(final Predicate<? super T>...
the predicates to check, cloned, not null
predicates
)

Factory to create the predicate.

public static <
the type that the predicate queries
T
>
Predicate<T>

Returns:

the one predicate
onePredicate
(final Collection<? extends Predicate<? super T>>
the predicates to check, cloned, not null
predicates
)

Factory to create the predicate.

Inherited from org.apache.commons.collections4.functors.AbstractQuantifierPredicate:
getPredicates

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.functors.AbstractQuantifierPredicate.serialVersionUID.

Serial version UID

Constructor Detail

OnePredicateback to summary
public OnePredicate(final Predicate<? super T>... predicates)

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

Parameters
predicates:Predicate<? super T>[]

the predicates to check, not cloned, not null

Method Detail

evaluateback to summary
public boolean evaluate(final T object)

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

Evaluates the predicate returning true if only one decorated predicate returns true.

Parameters
object:T

the input object

Returns:boolean

true if only one decorated predicate returns true

Annotations
@Override
onePredicateback to summary
public static <T> Predicate<T> onePredicate(final Predicate<? super T>... predicates)

Factory to create the predicate.

If the array is size zero, the predicate always returns false. If the array is size one, then that predicate is returned.

Parameters
<T>
the type that the predicate queries
predicates:Predicate<? super T>[]

the predicates to check, cloned, not null

Returns:Predicate<T>

the any predicate

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
  • if the predicates array is null
  • if any predicate in the array is null
onePredicateback to summary
public static <T> Predicate<T> onePredicate(final Collection<? extends Predicate<? super T>> predicates)

Factory to create the predicate.

Parameters
<T>
the type that the predicate queries
predicates:Collection<? extends Predicate<? super T>>

the predicates to check, cloned, not null

Returns:Predicate<T>

the one predicate

Exceptions
NullPointerException:
  • if the predicates array is null
  • if any predicate in the array is null