Class TypeDescription


  • public class TypeDescription
    extends java.lang.Object
    Provides additional runtime information necessary to create a custom Java instance. In general this class is thread-safe and can be used as a singleton, the only exception being the PropertyUtils field. A singleton PropertyUtils should be constructed and shared between all YAML Constructors used if a singleton TypeDescription is used, since Constructor sets its propertyUtils to the TypeDescription that is passed to it, hence you may end up in a situation when propertyUtils in TypeDescription is from different Constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz)  
      TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz, java.lang.Class<?> impl)  
      TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz, java.lang.String tag)  
      TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz, Tag tag)  
      TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz, Tag tag, java.lang.Class<?> impl)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addPropertyParameters​(java.lang.String pName, java.lang.Class<?>... classes)
      Adds new substitute for property pName parameterized by classes to this TypeDescription.
      private void checkDelegates()  
      private Property discoverProperty​(java.lang.String name)  
      java.lang.Object finalizeConstruction​(java.lang.Object obj)
      Is invoked after entity is filled with values from deserialized YAML
      java.lang.Class<? extends java.lang.Object> getListPropertyType​(java.lang.String property)
      Deprecated.
      java.lang.Class<? extends java.lang.Object> getMapKeyType​(java.lang.String property)
      Deprecated.
      java.lang.Class<? extends java.lang.Object> getMapValueType​(java.lang.String property)
      Deprecated.
      java.util.Set<Property> getProperties()  
      Property getProperty​(java.lang.String name)  
      Tag getTag()
      Get tag which shall be used to load or dump the type (class).
      java.lang.Class<? extends java.lang.Object> getType()
      Get represented type (class)
      java.lang.Object newInstance​(java.lang.String propertyName, Node node)  
      java.lang.Object newInstance​(Node node)
      This method should be overridden for TypeDescription implementations that are supposed to implement instantiation logic that is different from default one as implemented in YAML constructors.
      void putListPropertyType​(java.lang.String property, java.lang.Class<? extends java.lang.Object> type)
      Deprecated.
      void putMapPropertyType​(java.lang.String property, java.lang.Class<? extends java.lang.Object> key, java.lang.Class<? extends java.lang.Object> value)
      Deprecated.
      void setExcludes​(java.lang.String... propNames)  
      void setIncludes​(java.lang.String... propNames)  
      boolean setProperty​(java.lang.Object targetBean, java.lang.String propertyName, java.lang.Object value)  
      void setPropertyUtils​(PropertyUtils propertyUtils)  
      boolean setupPropertyType​(java.lang.String key, Node valueNode)  
      void substituteProperty​(java.lang.String pName, java.lang.Class<?> pType, java.lang.String getter, java.lang.String setter, java.lang.Class<?>... argParams)
      Adds property substitute for pName
      void substituteProperty​(PropertySubstitute substitute)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • log

        private static final java.util.logging.Logger log
      • type

        private final java.lang.Class<? extends java.lang.Object> type
      • impl

        private java.lang.Class<?> impl
      • tag

        private final Tag tag
      • dumpProperties

        private transient java.util.Set<Property> dumpProperties
      • delegatesChecked

        private transient boolean delegatesChecked
      • excludes

        protected java.util.Set<java.lang.String> excludes
      • includes

        protected java.lang.String[] includes
    • Constructor Detail

      • TypeDescription

        public TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz,
                               Tag tag)
      • TypeDescription

        public TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz,
                               Tag tag,
                               java.lang.Class<?> impl)
      • TypeDescription

        public TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz,
                               java.lang.String tag)
      • TypeDescription

        public TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz)
      • TypeDescription

        public TypeDescription​(java.lang.Class<? extends java.lang.Object> clazz,
                               java.lang.Class<?> impl)
    • Method Detail

      • getTag

        public Tag getTag()
        Get tag which shall be used to load or dump the type (class).
        Returns:
        tag to be used. It may be a tag for Language-Independent Types (http://www.yaml.org/type/)
      • getType

        public java.lang.Class<? extends java.lang.Object> getType()
        Get represented type (class)
        Returns:
        type (class) to be described.
      • putListPropertyType

        @Deprecated
        public void putListPropertyType​(java.lang.String property,
                                        java.lang.Class<? extends java.lang.Object> type)
        Deprecated.
        Specify that the property is a type-safe List.
        Parameters:
        property - name of the JavaBean property
        type - class of List values
      • getListPropertyType

        @Deprecated
        public java.lang.Class<? extends java.lang.Object> getListPropertyType​(java.lang.String property)
        Deprecated.
        Get class of List values for provided JavaBean property.
        Parameters:
        property - property name
        Returns:
        class of List values
      • putMapPropertyType

        @Deprecated
        public void putMapPropertyType​(java.lang.String property,
                                       java.lang.Class<? extends java.lang.Object> key,
                                       java.lang.Class<? extends java.lang.Object> value)
        Deprecated.
        Specify that the property is a type-safe Map.
        Parameters:
        property - property name of this JavaBean
        key - class of keys in Map
        value - class of values in Map
      • getMapKeyType

        @Deprecated
        public java.lang.Class<? extends java.lang.Object> getMapKeyType​(java.lang.String property)
        Deprecated.
        Get keys type info for this JavaBean
        Parameters:
        property - property name of this JavaBean
        Returns:
        class of keys in the Map
      • getMapValueType

        @Deprecated
        public java.lang.Class<? extends java.lang.Object> getMapValueType​(java.lang.String property)
        Deprecated.
        Get values type info for this JavaBean
        Parameters:
        property - property name of this JavaBean
        Returns:
        class of values in the Map
      • addPropertyParameters

        public void addPropertyParameters​(java.lang.String pName,
                                          java.lang.Class<?>... classes)
        Adds new substitute for property pName parameterized by classes to this TypeDescription. If pName has been added before - updates parameters with classes.
        Parameters:
        pName - - parameter name
        classes - - parameterized by
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • checkDelegates

        private void checkDelegates()
      • discoverProperty

        private Property discoverProperty​(java.lang.String name)
      • getProperty

        public Property getProperty​(java.lang.String name)
      • substituteProperty

        public void substituteProperty​(java.lang.String pName,
                                       java.lang.Class<?> pType,
                                       java.lang.String getter,
                                       java.lang.String setter,
                                       java.lang.Class<?>... argParams)
        Adds property substitute for pName
        Parameters:
        pName - property name
        pType - property type
        getter - method name for getter
        setter - method name for setter
        argParams - actual types for parameterized type (List<?>, Map<?>)
      • setPropertyUtils

        public void setPropertyUtils​(PropertyUtils propertyUtils)
      • setIncludes

        public void setIncludes​(java.lang.String... propNames)
      • setExcludes

        public void setExcludes​(java.lang.String... propNames)
      • getProperties

        public java.util.Set<Property> getProperties()
      • setupPropertyType

        public boolean setupPropertyType​(java.lang.String key,
                                         Node valueNode)
      • setProperty

        public boolean setProperty​(java.lang.Object targetBean,
                                   java.lang.String propertyName,
                                   java.lang.Object value)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • newInstance

        public java.lang.Object newInstance​(Node node)
        This method should be overridden for TypeDescription implementations that are supposed to implement instantiation logic that is different from default one as implemented in YAML constructors. Note that even if you override this method, default filling of fields with variables from parsed YAML will still occur later.
        Parameters:
        node - - node to construct the instance from
        Returns:
        new instance
      • newInstance

        public java.lang.Object newInstance​(java.lang.String propertyName,
                                            Node node)
      • finalizeConstruction

        public java.lang.Object finalizeConstruction​(java.lang.Object obj)
        Is invoked after entity is filled with values from deserialized YAML
        Parameters:
        obj - - deserialized entity
        Returns:
        postprocessed deserialized entity