public class DefaultObjectTypeDeterminer extends Object implements ObjectTypeDeterminer
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.
Modifier and Type | Field and Description |
---|---|
static String |
CREATE_IF_NULL_PREFIX |
static String |
DEPRECATED_ELEMENT_PREFIX |
static String |
ELEMENT_PREFIX |
static String |
KEY_PREFIX |
static String |
KEY_PROPERTY_PREFIX |
protected static org.apache.logging.log4j.Logger |
LOG |
Constructor and Description |
---|
DefaultObjectTypeDeterminer(XWorkConverter converter,
ReflectionProvider provider) |
Modifier and Type | Method and Description |
---|---|
protected <T extends Annotation> |
getAnnotation(Class parentClass,
String property,
Class<T> annotationClass)
Retrieves an annotation for the specified property of field, setter or getter.
|
Class |
getElementClass(Class parentClass,
String property,
Object key)
Determines the element class by looking for the value of @Element annotation for the given
class.
|
Class |
getKeyClass(Class parentClass,
String property)
Determines the key class by looking for the value of @Key annotation for the given class.
|
String |
getKeyProperty(Class parentClass,
String property)
Determines the key property for a Collection by getting it from the @KeyProperty annotation.
|
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.
|
protected static final org.apache.logging.log4j.Logger LOG
public static final String KEY_PREFIX
public static final String ELEMENT_PREFIX
public static final String KEY_PROPERTY_PREFIX
public static final String CREATE_IF_NULL_PREFIX
public static final String DEPRECATED_ELEMENT_PREFIX
public DefaultObjectTypeDeterminer(XWorkConverter converter, ReflectionProvider provider)
public Class getKeyClass(Class parentClass, String property)
getKeyClass
in interface ObjectTypeDeterminer
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 classObjectTypeDeterminer.getKeyClass(Class, String)
public Class getElementClass(Class parentClass, String property, Object key)
getElementClass
in interface ObjectTypeDeterminer
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 classObjectTypeDeterminer.getElementClass(Class, String, Object)
public String getKeyProperty(Class parentClass, String property)
getKeyProperty
in interface ObjectTypeDeterminer
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 classObjectTypeDeterminer.getKeyProperty(Class, String)
public boolean shouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed)
shouldCreateIfNew
in interface ObjectTypeDeterminer
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 classtarget
- the target objectkeyProperty
- the keyProperty valueisIndexAccessed
- true, if the collection or map is accessed via index, false otherwise.ObjectTypeDeterminer.getKeyProperty(Class, String)
protected <T extends Annotation> T getAnnotation(Class parentClass, String property, Class<T> annotationClass)
T
- the annotation type to be retrievedparentClass
- the classproperty
- the propertyannotationClass
- the annotationnull
if not foundCopyright © 2000–2020 Apache Software Foundation. All rights reserved.