Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2.util
Class GenericsObjectTypeDeterminer

    java.lang.Object
      com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer
          com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer

All Implemented Interfaces:
  ObjectTypeDeterminer

    public class GenericsObjectTypeDeterminer

extends DefaultObjectTypeDeterminer

GenericsObjectTypeDeterminer

Author:
  Patrick Lightbody, Rainer Hermanns, Alexandru Popescu

Field Summary

Fields inherited from class com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer
`CREATE_IF_NULL_PREFIX, DEPRECATED_ELEMENT_PREFIX, ELEMENT_PREFIX, KEY_PREFIX, KEY_PROPERTY_PREFIX, LOG`

Constructor Summary
`GenericsObjectTypeDeterminer()`

Method Summary
`protected
`<T extends Annotation> T`
` | `getAnnotation(Class parentClass, String property, Class<T> annotationClass)` Retrieves an annotation for the specified property of field, setter or getter.
`private
`<T extends Annotation> T`
` | `getAnnotationFromGetter(Class parentClass, String property, Class<T> annotationClass)` Retrieves an annotation for the specified field of getter.
`private
`<T extends Annotation> T`
` | `getAnnotationFromSetter(Class parentClass, String property, Class<T> annotationClass)` Retrieves an annotation for the specified field of setter.
`private Class` | `getClass(Class parentClass, String property, boolean element)` Returns the class for the given field via generic type check.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GenericsObjectTypeDeterminer

    public GenericsObjectTypeDeterminer()

Method Detail

### getKeyClass

    public Class getKeyClass(Class parentClass,
                             String property)

  Determines the key class by looking for the value of @Key annotation for the given class. If no annotation is found, the key class is determined by using the generic parametrics.

  Specified by:
    `getKeyClass` in interface `ObjectTypeDeterminer`
  Overrides:
    `getKeyClass` in class `DefaultObjectTypeDeterminer`
  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:
    `ObjectTypeDeterminer.getKeyClass(Class, String)`

### getElementClass

    public Class getElementClass(Class parentClass,
                                 String property,
                                 Object key)

  Determines the element class by looking for the value of @Element annotation for the given class. If no annotation is found, the element class is determined by using the generic parametrics.

  Specified by:
    `getElementClass` in interface `ObjectTypeDeterminer`
  Overrides:
    `getElementClass` in class `DefaultObjectTypeDeterminer`
  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:
    `ObjectTypeDeterminer.getElementClass(Class, String, Object)`

### getKeyProperty

    public String getKeyProperty(Class parentClass,
                                 String property)

  Determines the key property for a Collection by getting it from the @KeyProperty annotation.

  Specified by:
    `getKeyProperty` in interface `ObjectTypeDeterminer`
  Overrides:
    `getKeyProperty` in class `DefaultObjectTypeDeterminer`
  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:
    `ObjectTypeDeterminer.getKeyProperty(Class, String)`

### shouldCreateIfNew

    public 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.

  Specified by:
    `shouldCreateIfNew` in interface `ObjectTypeDeterminer`
  Overrides:
    `shouldCreateIfNew` in class `DefaultObjectTypeDeterminer`
  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` -
    `keyProperty` -
    `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:
    `ObjectTypeDeterminer.getKeyProperty(Class, String)`

### getAnnotation

    protected <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 `null` if not found

### getAnnotationFromGetter

    private <T extends Annotation> T getAnnotationFromGetter(Class parentClass,
                                                             String property,
                                                             Class<T> annotationClass)

  Retrieves an annotation for the specified field of getter.

  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
    `annotationClass` - The annotation
  Returns:
    concrete Annotation instance or `null` if none could be retrieved.

### getAnnotationFromSetter

    private <T extends Annotation> T getAnnotationFromSetter(Class parentClass,
                                                             String property,
                                                             Class<T> annotationClass)

  Retrieves an annotation for the specified field of setter.

  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
    `annotationClass` - The annotation
  Returns:
    concrete Annotation instance or `null` if none could be retrieved.

### getClass

    private Class getClass(Class parentClass,
                           String property,
                           boolean element)

  Returns the class for the given field via generic type check.

  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
    `element` - `true` for indexed types and Maps.
  Returns:
    Class of the specified field.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.