Class FindWithinGenerator<E>
- java.lang.Object
-
- org.apache.commons.functor.core.algorithm.FindWithinGenerator<E>
-
- Type Parameters:
E- the arguments type.
- All Implemented Interfaces:
java.io.Serializable,BinaryFunction<Generator<? extends E>,UnaryPredicate<? super E>,E>,BinaryFunctor<Generator<? extends E>,UnaryPredicate<? super E>>,Functor
public final class FindWithinGenerator<E> extends java.lang.Object implements BinaryFunction<Generator<? extends E>,UnaryPredicate<? super E>,E>, java.io.Serializable
Return the first Object in aGeneratormatching aUnaryPredicate.- Version:
- $Revision$ $Date$
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFindWithinGenerator.FindProcedure<T>Helper procedure.
-
Field Summary
Fields Modifier and Type Field Description private EifNoneObject to be returned in the case the adapted procedure does not find any object.static FindWithinGenerator<java.lang.Object>INSTANCEBasic instance.private static longserialVersionUIDserialVersionUID declaration.private booleanuseIfNoneFlag to mark theevaluate(Generator, UnaryPredicate)method must return a user defined object when the adapted procedure does not find any object.
-
Constructor Summary
Constructors Constructor Description FindWithinGenerator()Create a new FindWithinGenerator.FindWithinGenerator(E ifNone)Create a new FindWithinGenerator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Indicates whether some other object is "equal to" this functor.Eevaluate(Generator<? extends E> left, UnaryPredicate<? super E> right)Evaluate this function.inthashCode()Returns a hash code for this functor adhering to the generalObject.hashCodecontract.static FindWithinGenerator<java.lang.Object>instance()Get a staticFindWithinGeneratorinstance.
-
-
-
Field Detail
-
INSTANCE
public static final FindWithinGenerator<java.lang.Object> INSTANCE
Basic instance.
-
serialVersionUID
private static final long serialVersionUID
serialVersionUID declaration.- See Also:
- Constant Field Values
-
useIfNone
private final boolean useIfNone
Flag to mark theevaluate(Generator, UnaryPredicate)method must return a user defined object when the adapted procedure does not find any object.
-
ifNone
private final E ifNone
Object to be returned in the case the adapted procedure does not find any object.
-
-
Constructor Detail
-
FindWithinGenerator
public FindWithinGenerator()
Create a new FindWithinGenerator.
-
FindWithinGenerator
public FindWithinGenerator(E ifNone)
Create a new FindWithinGenerator.- Parameters:
ifNone- object to return if the Generator contains no matches.
-
-
Method Detail
-
evaluate
public E evaluate(Generator<? extends E> left, UnaryPredicate<? super E> right)
Evaluate this function.- Specified by:
evaluatein interfaceBinaryFunction<Generator<? extends E>,UnaryPredicate<? super E>,E>- Parameters:
left- Generatorright- UnaryPredicate- Returns:
- the T result of this function for the given arguments
-
equals
public boolean equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this functor. This method must adhere to generalObject.equalscontract. Additionally, this method can return true only if the specified Object implements the same functor interface and is known to produce the same results and/or side-effects for the same arguments (if any).While implementators are strongly encouraged to override the default Object implementation of this method, note that the default Object implementation does in fact adhere to the functor
equalscontract.- Specified by:
equalsin interfaceFunctor- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare this functor to- Returns:
trueiff the given object implements this functor interface, and is known to produce the same results and/or side-effects for the same arguments (if any).- See Also:
Functor.hashCode()
-
hashCode
public int hashCode()
Returns a hash code for this functor adhering to the generalObject.hashCodecontract. Implementators are strongly encouraged but not strictly required to override the defaultObjectimplementation of this method.- Specified by:
hashCodein interfaceFunctor- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code for this functor
- See Also:
Functor.equals(java.lang.Object)
-
instance
public static FindWithinGenerator<java.lang.Object> instance()
Get a staticFindWithinGeneratorinstance.- Returns:
FindWithinGenerator
-
-