com.github.fge.jsonschema.core.util
Class ValueHolder<T>

java.lang.Object
  extended by com.github.fge.jsonschema.core.util.ValueHolder<T>
Type Parameters:
T - the type of the value
All Implemented Interfaces:
MessageProvider

@Immutable
public abstract class ValueHolder<T>
extends Object
implements MessageProvider

A wrapper over an arbitrary type to be used by processors

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.


Field Summary
protected static JsonNodeFactory FACTORY
           
protected  T value
           
 
Constructor Summary
protected ValueHolder(String name, T value)
          Protected constructor
 
Method Summary
 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>
ValueHolder<V>
hold(String name, V value)
           
static
<V> ValueHolder<V>
hold(V value)
           
static
<V extends AsJson>
ValueHolder<V>
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY

protected static final JsonNodeFactory FACTORY

value

protected final T value
Constructor Detail

ValueHolder

protected ValueHolder(String name,
                      T value)
Protected constructor

Parameters:
name - the name to prefix the value with
value - the value
Method Detail

hold

public static <V> ValueHolder<V> hold(V value)

hold

public static <V> ValueHolder<V> hold(String name,
                                      V value)

hold

public static <V extends AsJson> ValueHolder<V> hold(V value)

hold

public static <V extends AsJson> ValueHolder<V> hold(String name,
                                                     V value)

valueAsJson

protected abstract JsonNode valueAsJson()
Return a JSON representation of the value

Returns:
a JsonNode

getName

public final String getName()
Return the declared name for this value

Returns:
the declared name

getValue

public final T getValue()
Get the value wrapped in the instance

Returns:
the value

newMessage

public final ProcessingMessage newMessage()
Create a new processing message template depending on the stored value

Specified by:
newMessage in interface MessageProvider
Returns:
a new ProcessingMessage