Package com.networknt.schema
Class CollectorContext
java.lang.Object
com.networknt.schema.CollectorContext
Context for holding data which can be set by custom walkers or validators and
can be retrieved later from the execution context.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor will use an unsynchronized HashMap to store data.CollectorContext(Map<Object, Object> data) Constructor that creates the context using the specified instances to store data. -
Method Summary
-
Constructor Details
-
CollectorContext
public CollectorContext()Default constructor will use an unsynchronized HashMap to store data. This is suitable if the collector context is not shared with multiple threads. -
CollectorContext
Constructor that creates the context using the specified instances to store data.If for instance the collector context needs to be shared with multiple threads a ConcurrentHashMap can be used.
It is however more likely that the data will only be used after the walk or validation is complete rather then during processing.
- Parameters:
data- the data map
-
-
Method Details
-
put
Sets data associated with a given key.- Type Parameters:
T- the return type- Parameters:
key- the keyvalue- the value- Returns:
- the previous value
-
get
Gets the data associated with a given key.- Type Parameters:
T- the return type- Parameters:
key- the key- Returns:
- the value
-
computeIfAbsent
Computes the value if absent.- Type Parameters:
T- the return type- Parameters:
key- the keymappingFunction- the mapping function- Returns:
- the value
-
getData
Gets the data map.- Returns:
- the data map
-