Class DefaultObjectTypeDeterminer
java.lang.Object
org.apache.struts2.conversion.impl.DefaultObjectTypeDeterminer
- All Implemented Interfaces:
- ObjectTypeDeterminer
 This 
ObjectTypeDeterminer looks at the Class-conversion.properties for entries that indicated what
 objects are contained within Maps and Collections. For Collections, such as Lists, the element is specified using the
 pattern Element_xxx, where xxx is the field name of the collection property in your action or object. For
 Maps, both the key and the value may be specified by using the pattern Key_xxx and Element_xxx,
 respectively.
 From WebWork 2.1.x, the Collection_xxx format is still supported and honored, although it is deprecated and will be removed eventually.
- Author:
- Gabriel Zimmerman
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultObjectTypeDeterminer(XWorkConverter converter, ReflectionProvider provider) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected <T extends Annotation>
 TgetAnnotation(Class parentClass, String property, Class<T> annotationClass) Retrieves an annotation for the specified property of field, setter or getter.getElementClass(Class parentClass, String property, Object key) Determines the element class by looking for the value of @Element annotation for the given class.getKeyClass(Class parentClass, String property) Determines the key class by looking for the value of @Key annotation for the given class.getKeyProperty(Class parentClass, String property) Determines the key property for a Collection by getting it from the @KeyProperty annotation.booleanshouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed) Determines the createIfNull property for a Collection or Map by getting it from the @CreateIfNull annotation.
- 
Field Details- 
LOGprotected static final org.apache.logging.log4j.Logger LOG
- 
KEY_PREFIX- See Also:
 
- 
ELEMENT_PREFIX- See Also:
 
- 
KEY_PROPERTY_PREFIX- See Also:
 
- 
CREATE_IF_NULL_PREFIX- See Also:
 
- 
DEPRECATED_ELEMENT_PREFIX- See Also:
 
 
- 
- 
Constructor Details- 
DefaultObjectTypeDeterminer
 
- 
- 
Method Details- 
getKeyClassDetermines the key class by looking for the value of @Key annotation for the given class. If no annotation is found, it determines the key class by looking for the value of Key_${property} in the properties file for the given class. As fallback, the key class is determined by using the generic parametrics.- Specified by:
- getKeyClassin interface- ObjectTypeDeterminer
- Parameters:
- parentClass- the Class which contains as a property the Map or Collection we are finding the key for.
- property- the property of the Map or Collection for the given parent class
- See Also:
 
- 
getElementClassDetermines the element class by looking for the value of @Element annotation for the given class. If no annotation is found, it determines the key class by looking for the value of Element_${property} in the properties file for the given class. Also looks for the deprecated Collection_${property} As fallback, the element class is determined by using the generic parametrics.- Specified by:
- getElementClassin interface- ObjectTypeDeterminer
- Parameters:
- parentClass- the Class which contains as a property the Map or Collection we are finding the key for.
- property- the property of the Map or Collection for the given parent class
- See Also:
 
- 
getKeyPropertyDetermines the key property for a Collection by getting it from the @KeyProperty annotation. As fallback, it determines the String key property for a Collection by getting it from the conversion properties file using the KeyProperty_ prefix. KeyProperty_${property}=somePropertyOfBeansInTheSet- Specified by:
- getKeyPropertyin interface- ObjectTypeDeterminer
- Parameters:
- parentClass- the Class which contains as a property the Map or Collection we are finding the key for.
- property- the property of the Map or Collection for the given parent class
- See Also:
 
- 
shouldCreateIfNewpublic boolean shouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed) Determines the createIfNull property for a Collection or Map by getting it from the @CreateIfNull annotation. As fallback, it determines the boolean CreateIfNull property for a Collection or Map by getting it from the conversion properties file using the CreateIfNull_ prefix. CreateIfNull_${property}=true|false- Specified by:
- shouldCreateIfNewin interface- ObjectTypeDeterminer
- Parameters:
- parentClass- the Class which contains as a property the Map or Collection we are finding the key for.
- property- the property of the Map or Collection for the given parent class
- target- the target object
- keyProperty- the keyProperty value
- isIndexAccessed- true, if the collection or map is accessed via index, false otherwise.
- Returns:
- true, if the Collection or Map should be created, false otherwise.
- See Also:
 
- 
getAnnotationprotected <T extends Annotation> T getAnnotation(Class parentClass, String property, Class<T> annotationClass) Retrieves an annotation for the specified property of field, setter or getter.- Type Parameters:
- T- the annotation type to be retrieved
- Parameters:
- parentClass- the class
- property- the property
- annotationClass- the annotation
- Returns:
- the field or setter/getter annotation or nullif not found
 
 
-