Package org.apache.commons.functor.core
Class Limit
java.lang.Object
org.apache.commons.functor.core.Limit
- All Implemented Interfaces:
BinaryFunctor<Object,,Object> BinaryPredicate<Object,,Object> Functor,NullaryFunctor,Predicate,UnaryFunctor<Object>,UnaryPredicate<Object>
public final class Limit
extends Object
implements Predicate, UnaryPredicate<Object>, BinaryPredicate<Object,Object>
A predicate that returns
true
the first n times it is invoked.- Since:
- 1.0
- Version:
- $Revision$ $Date$
-
Field Details
-
max
private final int maxThe max number of times the predicate can be invoked. -
current
private int currentThe current number of times the predicate has been invoked.
-
-
Constructor Details
-
Limit
public Limit(int count) Create a new Limit.- Parameters:
count- limit
-
-
Method Details
-
test
public boolean test()Evaluate this predicate. -
test
Evaluate this predicate.- Specified by:
testin interfaceUnaryPredicate<Object>- Parameters:
obj- the A object to test- Returns:
- the result of this test
-
test
Evaluate this predicate.- Specified by:
testin interfaceBinaryPredicate<Object,Object> - Parameters:
a- the L element of the ordered pair of argumentsb- the R element of the ordered pair of arguments- Returns:
- the result of this test for the given arguments
-
toString
Returns a human readable description of this functor. Implementators are strongly encouraged but not strictly required to override the defaultObjectimplementation of this method.
-