public class ConstantTransformer<I,O> extends java.lang.Object implements Transformer<I,O>, java.io.Serializable
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.
Modifier and Type | Field and Description |
---|---|
static Transformer |
NULL_INSTANCE
Returns null each time
|
Constructor and Description |
---|
ConstantTransformer(O constantToReturn)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
static <I,O> Transformer<I,O> |
constantTransformer(O constantToReturn)
Transformer method that performs validation.
|
boolean |
equals(java.lang.Object obj) |
O |
getConstant()
Gets the constant.
|
int |
hashCode() |
static <I,O> Transformer<I,O> |
nullTransformer()
Get a typed null instance.
|
O |
transform(I input)
Transforms the input by ignoring it and returning the stored constant instead.
|
public static final Transformer NULL_INSTANCE
public ConstantTransformer(O constantToReturn)
constantTransformer
if you want that.constantToReturn
- the constant to return each timepublic static <I,O> Transformer<I,O> nullTransformer()
I
- the input typeO
- the output typepublic static <I,O> Transformer<I,O> constantTransformer(O constantToReturn)
I
- the input typeO
- the output typeconstantToReturn
- the constant object to return each time in the factoryconstant
factory.public O transform(I input)
transform
in interface Transformer<I,O>
input
- the input object which is ignoredpublic O getConstant()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"