Package org.yaml.snakeyaml
Class TypeDescription
- java.lang.Object
-
- org.yaml.snakeyaml.TypeDescription
-
public class TypeDescription extends 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.
-
-
Field Summary
Fields Modifier and Type Field Description protected BeanAccessbeanAccessprotected Set<String>excludesprotected String[]includes
-
Constructor Summary
Constructors Constructor Description TypeDescription(Class<? extends Object> clazz)TypeDescription(Class<? extends Object> clazz, Class<?> impl)TypeDescription(Class<? extends Object> clazz, String tag)TypeDescription(Class<? extends Object> clazz, Tag tag)TypeDescription(Class<? extends Object> clazz, Tag tag, Class<?> impl)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddPropertyParameters(String pName, Class<?>... classes)Adds new substitute for propertypNameparameterized byclassesto thisTypeDescription.ObjectfinalizeConstruction(Object obj)Is invoked after entity is filled with values from deserialized YAMLSet<Property>getProperties()PropertygetProperty(String name)TaggetTag()Get tag which shall be used to load or dump the type (class).Class<? extends Object>getType()Get represented type (class)ObjectnewInstance(String propertyName, Node node)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(String property, Class<? extends Object> type)Deprecated.voidputMapPropertyType(String property, Class<? extends Object> key, Class<? extends Object> value)Deprecated.voidsetExcludes(String... propNames)voidsetIncludes(String... propNames)booleansetProperty(Object targetBean, String propertyName, Object value)voidsetPropertyUtils(PropertyUtils propertyUtils)booleansetupPropertyType(String key, Node valueNode)voidsubstituteProperty(String pName, Class<?> pType, String getter, String setter, Class<?>... argParams)Adds property substitute forpNamevoidsubstituteProperty(PropertySubstitute substitute)StringtoString()
-
-
-
Field Detail
-
includes
protected String[] includes
-
beanAccess
protected BeanAccess beanAccess
-
-
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 Class<? extends Object> getType()
Get represented type (class)- Returns:
- type (class) to be described.
-
putListPropertyType
@Deprecated public void putListPropertyType(String property, Class<? extends 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(String property, Class<? extends Object> key, Class<? extends 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(String pName, Class<?>... classes)
Adds new substitute for propertypNameparameterized byclassesto thisTypeDescription. IfpNamehas been added before - updates parameters withclasses.- Parameters:
pName- - parameter nameclasses- - parameterized by
-
substituteProperty
public void substituteProperty(String pName, Class<?> pType, String getter, String setter, 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(String... propNames)
-
setExcludes
public void setExcludes(String... propNames)
-
setProperty
public boolean setProperty(Object targetBean, String propertyName, Object value) throws Exception
- Throws:
Exception
-
newInstance
public 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
-
-