public class ConstantTransformer extends java.lang.Object implements Transformer, 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 |
---|---|
private java.lang.Object |
iConstant
The closures to call in turn
|
static Transformer |
NULL_INSTANCE
Returns null each time
|
private static long |
serialVersionUID
Serial version UID
|
Constructor and Description |
---|
ConstantTransformer(java.lang.Object constantToReturn)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getConstant()
Gets the constant.
|
static Transformer |
getInstance(java.lang.Object constantToReturn)
Transformer method that performs validation.
|
java.lang.Object |
transform(java.lang.Object input)
Transforms the input by ignoring it and returning the stored constant instead.
|
private static final long serialVersionUID
public static final Transformer NULL_INSTANCE
private final java.lang.Object iConstant
public ConstantTransformer(java.lang.Object constantToReturn)
getInstance
if you want that.constantToReturn
- the constant to return each timepublic static Transformer getInstance(java.lang.Object constantToReturn)
constantToReturn
- the constant object to return each time in the factoryconstant
factory.public java.lang.Object transform(java.lang.Object input)
transform
in interface Transformer
input
- the input object which is ignoredpublic java.lang.Object getConstant()