Class BaseConstructor

    • Field Detail

      • yamlClassConstructors

        protected final Map<NodeId,​Construct> yamlClassConstructors
        It maps the node kind to the the Construct implementation. When the runtime class is known then the implicit tag is ignored.
      • yamlConstructors

        protected final Map<Tag,​Construct> yamlConstructors
        It maps the (explicit or implicit) tag to the Construct implementation. It is used: 1) explicit tag - if present. 2) implicit tag - when the runtime class of the instance is unknown (the node has the Object.class)
      • yamlMultiConstructors

        protected final Map<String,​Construct> yamlMultiConstructors
        It maps the (explicit or implicit) tag to the Construct implementation. It is used when no exact match found.
      • rootTag

        protected Tag rootTag
    • Constructor Detail

      • BaseConstructor

        public BaseConstructor()
    • Method Detail

      • setComposer

        public void setComposer​(Composer composer)
      • checkData

        public boolean checkData()
        Check if more documents available
        Returns:
        true when there are more YAML documents in the stream
      • getData

        public Object getData()
        Construct and return the next document
        Returns:
        constructed instance
      • getSingleData

        public Object getSingleData​(Class<?> type)
        Ensure that the stream contains a single document and construct it
        Parameters:
        type - the class of the instance being created
        Returns:
        constructed instance
        Throws:
        ComposerException - in case there are more documents in the stream
      • constructDocument

        protected final Object constructDocument​(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​(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​(Node node)
      • getConstructor

        protected Construct getConstructor​(Node node)
        Get the constructor to construct the Node. For implicit tags if the runtime class is known a dedicated Construct implementation is used. Otherwise the constructor is chosen by the tag.
        Parameters:
        node - Node to construct an instance from
        Returns:
        Construct implementation for the specified node
      • createDefaultList

        protected List<Object> createDefaultList​(int initSize)
      • createDefaultSet

        protected Set<Object> createDefaultSet​(int initSize)
      • createDefaultMap

        protected Map<Object,​Object> createDefaultMap​(int initSize)
      • createArray

        protected Object createArray​(Class<?> type,
                                     int size)
      • finalizeConstruction

        protected Object finalizeConstruction​(Node node,
                                              Object data)
      • newInstance

        protected Object newInstance​(Node node)
      • setPropertyUtils

        public void setPropertyUtils​(PropertyUtils propertyUtils)
      • getPropertyUtils

        public final PropertyUtils getPropertyUtils()
      • addTypeDescription

        public TypeDescription addTypeDescription​(TypeDescription definition)
        Make YAML aware how to parse a custom Class. If there is no root Class assigned in constructor then the 'root' property of this definition is respected.
        Parameters:
        definition - to be added to the Constructor
        Returns:
        the previous value associated with definition, or null if there was no mapping for definition.
      • isExplicitPropertyUtils

        public final boolean isExplicitPropertyUtils()
      • isAllowDuplicateKeys

        public boolean isAllowDuplicateKeys()
      • setAllowDuplicateKeys

        public void setAllowDuplicateKeys​(boolean allowDuplicateKeys)