public class ConstantTransformer extends Object implements Transformer, 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(Object constantToReturn)
Constructor that performs no validation.
|
Modifier and Type | Method and Description |
---|---|
Object |
getConstant()
Gets the constant.
|
static Transformer |
getInstance(Object constantToReturn)
Transformer method that performs validation.
|
Object |
transform(Object input)
Transforms the input by ignoring it and returning the stored constant instead.
|
public static final Transformer NULL_INSTANCE
public ConstantTransformer(Object constantToReturn)
getInstance
if you want that.constantToReturn
- the constant to return each timepublic static Transformer getInstance(Object constantToReturn)
constantToReturn
- the constant object to return each time in the factoryconstant
factory.public Object transform(Object input)
transform
in interface Transformer
input
- the input object which is ignoredpublic Object getConstant()
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.