Package com.networknt.schema
Class CollectorContext
- java.lang.Object
-
- com.networknt.schema.CollectorContext
-
-
Constructor Summary
Constructors Constructor Description CollectorContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <E> void
add(String name, Collector<E> collector)
Adds a collector with give name.<E> void
add(String name, Object object)
Adds a collector or a simple object with give name.void
combineWithCollector(String name, Object data)
Combines data with Collector identified by the given name.Object
get(String name)
Gets the data associated with a given name.Map<String,Object>
getAll()
Returns all the collected data.Collection<String>
getEvaluatedItems()
Identifies which array items have been evaluated.Collection<String>
getEvaluatedProperties()
Identifies which properties have been evaluated.static CollectorContext
getInstance()
void
reset()
Reset the contextvoid
resetEvaluatedItems()
Replaces the array items that have been evaluated with an empty collection.void
resetEvaluatedProperties()
Replaces the properties that have been evaluated with an empty collection.void
setEvaluatedItems(Collection<String> paths)
Set the array items that have been evaluated.void
setEvaluatedProperties(Collection<String> paths)
Set the properties that have been evaluated.
-
-
-
Method Detail
-
getInstance
public static CollectorContext getInstance()
-
getEvaluatedItems
public Collection<String> getEvaluatedItems()
Identifies which array items have been evaluated.- Returns:
- the set of evaluated items (never null)
-
setEvaluatedItems
public void setEvaluatedItems(Collection<String> paths)
Set the array items that have been evaluated.- Parameters:
paths
- the set of evaluated array items (may be null)
-
resetEvaluatedItems
public void resetEvaluatedItems()
Replaces the array items that have been evaluated with an empty collection.
-
getEvaluatedProperties
public Collection<String> getEvaluatedProperties()
Identifies which properties have been evaluated.- Returns:
- the set of evaluated properties (never null)
-
setEvaluatedProperties
public void setEvaluatedProperties(Collection<String> paths)
Set the properties that have been evaluated.- Parameters:
paths
- the set of evaluated properties (may be null)
-
resetEvaluatedProperties
public void resetEvaluatedProperties()
Replaces the properties that have been evaluated with an empty collection.
-
add
public <E> void add(String name, Collector<E> collector)
Adds a collector with give name. Preserving this method for backward compatibility.- Type Parameters:
E
- element- Parameters:
name
- Stringcollector
- Collector
-
add
public <E> void add(String name, Object object)
Adds a collector or a simple object with give name.- Type Parameters:
E
- element- Parameters:
object
- Objectname
- String
-
get
public Object get(String name)
Gets the data associated with a given name. Please note if you are collectingCollector
instances you should wait till the validation is complete to gather all data.When
CollectorContext
is used to collectCollector
instances for a particular key, this method will return theCollector
instance as long asloadCollectors()
method is not called. Once theloadCollectors()
method is called this method will return the actual data collected by collector.- Parameters:
name
- String- Returns:
- Object
-
getAll
public Map<String,Object> getAll()
Returns all the collected data. Please look intoget(String)
method for more details.- Returns:
- Map
-
combineWithCollector
public void combineWithCollector(String name, Object data)
Combines data with Collector identified by the given name.- Parameters:
name
- Stringdata
- Object
-
reset
public void reset()
Reset the context
-
-