Package org.yaml.snakeyaml
Class TypeDescription
- java.lang.Object
-
- org.yaml.snakeyaml.TypeDescription
-
public class TypeDescription extends java.lang.ObjectProvides 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.
-
-
Field Summary
Fields Modifier and Type Field Description protected BeanAccessbeanAccessprotected java.util.Set<java.lang.String>excludesprotected java.lang.String[]includes
-
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 voidaddPropertyParameters(java.lang.String pName, java.lang.Class<?>... classes)Adds new substitute for propertypNameparameterized byclassesto thisTypeDescription.java.lang.ObjectfinalizeConstruction(java.lang.Object obj)Is invoked after entity is filled with values from deserialized YAMLjava.util.Set<Property>getProperties()PropertygetProperty(java.lang.String name)TaggetTag()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.ObjectnewInstance(java.lang.String propertyName, Node node)java.lang.ObjectnewInstance(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.voidputListPropertyType(java.lang.String property, java.lang.Class<? extends java.lang.Object> type)Deprecated.voidputMapPropertyType(java.lang.String property, java.lang.Class<? extends java.lang.Object> key, java.lang.Class<? extends java.lang.Object> value)Deprecated.voidsetExcludes(java.lang.String... propNames)voidsetIncludes(java.lang.String... propNames)booleansetProperty(java.lang.Object targetBean, java.lang.String propertyName, java.lang.Object value)voidsetPropertyUtils(PropertyUtils propertyUtils)booleansetupPropertyType(java.lang.String key, Node valueNode)voidsubstituteProperty(java.lang.String pName, java.lang.Class<?> pType, java.lang.String getter, java.lang.String setter, java.lang.Class<?>... argParams)Adds property substitute forpNamevoidsubstituteProperty(PropertySubstitute substitute)java.lang.StringtoString()
-
-
-
Field Detail
-
excludes
protected java.util.Set<java.lang.String> excludes
-
includes
protected java.lang.String[] includes
-
beanAccess
protected BeanAccess beanAccess
-
-
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-safeList.- Parameters:
property- name of the JavaBean propertytype- 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-safeMap.- Parameters:
property- property name of this JavaBeankey- class of keys in Mapvalue- class of values in Map
-
addPropertyParameters
public void addPropertyParameters(java.lang.String pName, java.lang.Class<?>... classes)Adds new substitute for propertypNameparameterized byclassesto thisTypeDescription. IfpNamehas been added before - updates parameters withclasses.- Parameters:
pName- - parameter nameclasses- - parameterized by
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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 forpName- Parameters:
pName- property namepType- property typegetter- method name for gettersetter- method name for setterargParams- actual types for parameterized type (List<?>, Map<?>)
-
substituteProperty
public void substituteProperty(PropertySubstitute substitute)
-
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
-
-