public class ConstantTransformer<I,O> extends Objectimplements Transformer <I ,O>, 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 |
constantTransformer(O constantToReturn)
Transformer method that performs validation.
|
boolean |
equals(Object
|
O |
getConstant()
Gets the constant.
|
int |
hashCode()
|
static <I |
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 TransformerNULL_INSTANCE
public ConstantTransformer(O constantToReturn)
constantTransformer if you want that.
constantToReturn - the constant to return each time
public static <I,O> Transformer <I ,O> nullTransformer()
I - the input type
O - the output type
public static <I,O> Transformer <I ,O> constantTransformer(O constantToReturn)
I - the input type
O - the output type
constantToReturn - the constant object to return each time in the factory
constant factory.
public O transform(I input)
transform in interface
Transformer<I,O>
input - the input object which is ignored
public O getConstant()
public boolean equals(Objectobj)
public int hashCode()