public class ConstantTransformer<I,O> extends Object implements 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,O> Transformer<I,O> |
constantTransformer(O constantToReturn)
Transformer method that performs validation.
|
boolean |
equals(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()
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.