Class CollectorContext


  • public class CollectorContext
    extends Object
    Context for holding the output returned by the Collector implementations.
    • Constructor Detail

      • CollectorContext

        public CollectorContext()
      • CollectorContext

        public CollectorContext​(boolean disableUnevaluatedItems,
                                boolean disableUnevaluatedProperties)
    • Method Detail

      • enterDynamicScope

        public CollectorContext.Scope enterDynamicScope()
        Creates a new scope
        Returns:
        the previous, parent scope
      • enterDynamicScope

        public CollectorContext.Scope enterDynamicScope​(JsonSchema containingSchema)
        Creates a new scope
        Parameters:
        containingSchema - the containing schema
        Returns:
        the previous, parent scope
      • exitDynamicScope

        public CollectorContext.Scope exitDynamicScope()
        Restores the previous, parent scope
        Returns:
        the exited scope
      • getDynamicScope

        public CollectorContext.Scope getDynamicScope()
        Provides the currently active scope
        Returns:
        the active scope
      • getOutermostSchema

        public JsonSchema getOutermostSchema()
      • getEvaluatedItems

        public Collection<JsonNodePath> getEvaluatedItems()
        Identifies which array items have been evaluated.
        Returns:
        the set of evaluated items (never null)
      • getEvaluatedProperties

        public Collection<JsonNodePath> getEvaluatedProperties()
        Identifies which properties have been evaluated.
        Returns:
        the set of evaluated properties (never null)
      • 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 - String
        collector - 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 - Object
        name - String
      • get

        public Object get​(String name)
        Gets the data associated with a given name. Please note if you are collecting Collector instances you should wait till the validation is complete to gather all data.

        When CollectorContext is used to collect Collector instances for a particular key, this method will return the Collector instance as long as loadCollectors() method is not called. Once the loadCollectors() method is called this method will return the actual data collected by collector.

        Parameters:
        name - String
        Returns:
        Object
      • getCollectorMap

        public Map<String,​Object> getCollectorMap()
        Gets the collector map.
        Returns:
        the collector map
      • getAll

        public Map<String,​Object> getAll()
        Returns all the collected data. Please look into get(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 - String
        data - Object