Class ConstantTransformer<I,O>
java.lang.Object
org.apache.commons.collections4.functors.ConstantTransformer<I,O>
- All Implemented Interfaces:
Serializable
,Transformer<I,
O>
Transformer implementation that returns the same constant each time.
No check is made that the object is immutable. In general, only immutable objects should use the constant factory. Mutable objects should use the prototype factory.
- Since:
- 3.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final O
The closures to call in turnstatic final Transformer
Returns null each timeprivate static final long
Serial version UID -
Constructor Summary
ConstructorsConstructorDescriptionConstantTransformer
(O constantToReturn) Constructor that performs no validation. -
Method Summary
Modifier and TypeMethodDescriptionstatic <I,
O> Transformer <I, O> constantTransformer
(O constantToReturn) Transformer method that performs validation.boolean
Gets the constant.int
hashCode()
static <I,
O> Transformer <I, O> Get a typed null instance.Transforms the input by ignoring it and returning the stored constant instead.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial version UID- See Also:
-
NULL_INSTANCE
Returns null each time -
iConstant
The closures to call in turn
-
-
Constructor Details
-
ConstantTransformer
Constructor that performs no validation. UseconstantTransformer
if you want that.- Parameters:
constantToReturn
- the constant to return each time
-
-
Method Details
-
nullTransformer
Get a typed null instance.- Type Parameters:
I
- the input typeO
- the output type- Returns:
- Transformer<I, O> that always returns null.
-
constantTransformer
Transformer method that performs validation.- Type Parameters:
I
- the input typeO
- the output type- Parameters:
constantToReturn
- the constant object to return each time in the factory- Returns:
- the
constant
factory.
-
transform
Transforms the input by ignoring it and returning the stored constant instead.- Specified by:
transform
in interfaceTransformer<I,
O> - Parameters:
input
- the input object which is ignored- Returns:
- the stored constant
-
getConstant
Gets the constant.- Returns:
- the constant
- Since:
- 3.1
-
equals
-
hashCode
public int hashCode()
-