org.apache.commons.functor.core
Class Limit

java.lang.Object
  extended by 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: 1160412 $ $Date: 2011-08-22 22:10:41 +0200 (Mon, 22 Aug 2011) $
Author:
Jason Horman (jason@jhorman.org), Rodney Waldhoff

Constructor Summary
Limit(int count)
          Create a new Limit.
 
Method Summary
 boolean test()
          Evaluate this predicate.
 boolean test(Object obj)
          Evaluate this predicate.
 boolean test(Object a, Object b)
          Evaluate this predicate.
 String toString()
          Returns a human readable description of this functor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.functor.Functor
equals, hashCode
 

Constructor Detail

Limit

public Limit(int count)
Create a new Limit.

Parameters:
count - limit
Method Detail

test

public boolean test()
Evaluate this predicate.

Specified by:
test in interface Predicate
Returns:
the result of this test

test

public boolean test(Object obj)
Evaluate this predicate.

Specified by:
test in interface UnaryPredicate<Object>
Parameters:
obj - the A object to test
Returns:
the result of this test

test

public boolean test(Object a,
                    Object b)
Evaluate this predicate.

Specified by:
test in interface BinaryPredicate<Object,Object>
Parameters:
a - the L element of the ordered pair of arguments
b - the R element of the ordered pair of arguments
Returns:
the result of this test for the given arguments

toString

public String toString()
Returns a human readable description of this functor. Implementators are strongly encouraged but not strictly required to override the default Object implementation of this method.

Specified by:
toString in interface Functor
Overrides:
toString in class Object
Returns:
a human readable description of this functor


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.