Class BaseConstructor

    • Field Detail

      • tagConstructors

        protected final Map<org.snakeyaml.engine.v2.nodes.Tag,​ConstructNode> tagConstructors
        It maps the (explicit or implicit) tag to the Construct implementation.
      • settings

        protected LoadSettings settings
        keep the settings
    • Constructor Detail

      • BaseConstructor

        public BaseConstructor​(LoadSettings settings)
        Create
        Parameters:
        settings - - the configuration option
    • Method Detail

      • constructSingleDocument

        public Object constructSingleDocument​(Optional<org.snakeyaml.engine.v2.nodes.Node> optionalNode)
        Ensure that the stream contains a single document and construct it
        Parameters:
        optionalNode - - composed Node
        Returns:
        constructed instance
      • construct

        protected Object construct​(org.snakeyaml.engine.v2.nodes.Node node)
        Construct complete YAML document. Call the second step in case of recursive structures. At the end cleans all the state.
        Parameters:
        node - root Node
        Returns:
        Java instance
      • constructObject

        protected Object constructObject​(org.snakeyaml.engine.v2.nodes.Node node)
        Construct object from the specified Node. Return existing instance if the node is already constructed.
        Parameters:
        node - Node to be constructed
        Returns:
        Java instance
      • constructObjectNoCheck

        protected Object constructObjectNoCheck​(org.snakeyaml.engine.v2.nodes.Node node)
        Construct object from the specified Node. It does not check if existing instance the node is already constructed.
        Parameters:
        node - - the source
        Returns:
        instantiated object
      • findConstructorFor

        protected Optional<ConstructNode> findConstructorFor​(org.snakeyaml.engine.v2.nodes.Node node)
        Select ConstructNode inside the provided Node or the one associated with the Tag
        Parameters:
        node - Node to construct an instance from
        Returns:
        ConstructNode implementation for the specified node
      • constructScalar

        protected String constructScalar​(org.snakeyaml.engine.v2.nodes.ScalarNode node)
        Create String from the provided scalar node
        Parameters:
        node - - the source
        Returns:
        value of the scalar node
      • createEmptyListForNode

        protected List<Object> createEmptyListForNode​(org.snakeyaml.engine.v2.nodes.SequenceNode node)
        Create List implementation. By default, it returns the value configured in the settings in getDefaultList(). Any custom List implementation can be provided.
        Parameters:
        node - - the node to fill the List
        Returns:
        empty List to fill
      • createEmptySetForNode

        protected Set<Object> createEmptySetForNode​(org.snakeyaml.engine.v2.nodes.MappingNode node)
        Create Set implementation. By default, it returns the value configured in the settings in getDefaultSet(). Any custom Set implementation can be provided.
        Parameters:
        node - - the node to fill the Set
        Returns:
        empty Set to fill
      • createEmptyMapFor

        protected Map<Object,​Object> createEmptyMapFor​(org.snakeyaml.engine.v2.nodes.MappingNode node)
        Create Map implementation. By default, it returns the value configured in the settings in getDefaultMap(). Any custom Map implementation can be provided.
        Parameters:
        node - - the node to fill the Map
        Returns:
        empty Map to fill
      • constructSequence

        protected List<Object> constructSequence​(org.snakeyaml.engine.v2.nodes.SequenceNode node)
        Create instance of List
        Parameters:
        node - - the source
        Returns:
        filled List
      • constructSequenceStep2

        protected void constructSequenceStep2​(org.snakeyaml.engine.v2.nodes.SequenceNode node,
                                              Collection<Object> collection)
        Fill the collection with the data from provided node
        Parameters:
        node - - the source
        collection - - the collection to fill
      • constructSet

        protected Set<Object> constructSet​(org.snakeyaml.engine.v2.nodes.MappingNode node)
        Create instance of Set from mapping node
        Parameters:
        node - - the source
        Returns:
        filled Set
      • constructMapping

        protected Map<Object,​Object> constructMapping​(org.snakeyaml.engine.v2.nodes.MappingNode node)
        Create filled Map from the provided Node
        Parameters:
        node - - the source
        Returns:
        filled Map
      • constructMapping2ndStep

        protected void constructMapping2ndStep​(org.snakeyaml.engine.v2.nodes.MappingNode node,
                                               Map<Object,​Object> mapping)
        Fill the mapping with the data from provided node
        Parameters:
        node - - the source
        mapping - - empty map to be filled
      • postponeMapFilling

        protected void postponeMapFilling​(Map<Object,​Object> mapping,
                                          Object key,
                                          Object value)
        if keyObject is created it 2 steps we should postpone putting it in map because it may have different hash after initialization compared to clean just created one. And map of course does not observe key hashCode changes.
        Parameters:
        mapping - - the mapping to add key/value
        key - - the key to add to map
        value - - the value behind the key
      • constructSet2ndStep

        protected void constructSet2ndStep​(org.snakeyaml.engine.v2.nodes.MappingNode node,
                                           Set<Object> set)
        Fill the Map with the data from the node
        Parameters:
        node - - the source
        set - - empty set to fill
      • postponeSetFilling

        protected void postponeSetFilling​(Set<Object> set,
                                          Object key)
        if keyObject is created it 2 steps we should postpone putting it into the set because it may have different hash after initialization compared to clean just created one. And set of course does not observe value hashCode changes.
        Parameters:
        set - - the set to add the key
        key - - the item to add to the set