T
- the type of the value@Immutable public abstract class ValueHolder<T> extends Object implements MessageProvider
Since all inputs and outputs of a Processor
need to implement
MessageProvider
, this abstract class helps to wrap values and
implement this interface at the same time.
Implementations need only implement the valueAsJson()
method.
Modifier and Type | Field and Description |
---|---|
protected static JsonNodeFactory |
FACTORY |
protected T |
value |
Modifier | Constructor and Description |
---|---|
protected |
ValueHolder(String name,
T value)
Protected constructor
|
Modifier and Type | Method and Description |
---|---|
String |
getName()
Return the declared name for this value
|
T |
getValue()
Get the value wrapped in the instance
|
static <V> ValueHolder<V> |
hold(String name,
V value) |
static <V extends AsJson> |
hold(String name,
V value) |
static <V> ValueHolder<V> |
hold(V value) |
static <V extends AsJson> |
hold(V value) |
ProcessingMessage |
newMessage()
Create a new processing message template depending on the stored value
|
protected abstract JsonNode |
valueAsJson()
Return a JSON representation of the value
|
protected static final JsonNodeFactory FACTORY
protected final T value
public static <V> ValueHolder<V> hold(V value)
public static <V> ValueHolder<V> hold(String name, V value)
public static <V extends AsJson> ValueHolder<V> hold(V value)
public static <V extends AsJson> ValueHolder<V> hold(String name, V value)
protected abstract JsonNode valueAsJson()
JsonNode
public final String getName()
public final T getValue()
public final ProcessingMessage newMessage()
newMessage
in interface MessageProvider
ProcessingMessage