Class CollectorContext
java.lang.Object
com.networknt.schema.CollectorContext
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor will use an unsynchronized HashMap to store data.Constructor that creates the context using the specified instances to store data. -
Method Summary
Modifier and TypeMethodDescription<E> voidAdds a collector with give name.<E> voidAdds a collector or a simple object with give name.voidcombineWithCollector(String name, Object data) Combines data with Collector identified by the given name.Gets the data associated with a given name.getAll()Returns all the collected data.Gets the collector map.voidLoads data from all collectors.
-
Field Details
-
collectorMap
-
collectorLoadMap
-
-
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.
- Parameters:
collectorMap- the collector mapcollectorLoadMap- the collector load map
-
-
Method Details
-
add
-
add
-
get
Gets the data associated with a given name. Please note if you are collectingCollectorinstances you should wait till the validation is complete to gather all data.When
CollectorContextis used to collectCollectorinstances for a particular key, this method will return theCollectorinstance 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
-
getCollectorMap
-
getAll
Returns all the collected data. Please look intoget(String)method for more details.- Returns:
- Map
-
combineWithCollector
-
loadCollectors
public void loadCollectors()Loads data from all collectors.
-