org.apache.bval.util
Class KeyedAccess

java.lang.Object
  extended by org.apache.bval.util.AccessStrategy
      extended by org.apache.bval.util.KeyedAccess

public class KeyedAccess
extends AccessStrategy

AccessStrategy to get a keyed value from a Map. Contains special handling when a string key is used against a container type whose key parameter is not assignable from String: against a map whose key type is an enum class, it will be interpreted as a named enum constant; other key types will be compared via Object.toString().


Constructor Summary
KeyedAccess(Type containerType, Object key)
          Create a new KeyedAccess instance.
 
Method Summary
 Object get(Object instance)
          Get the value from the given instance.
 ElementType getElementType()
          Get the Java program ElementType used by this AccessStrategy to determine property values.
static Type getJavaElementType(Type containerType)
          Get the Java element type of a particular container type.
 Type getJavaType()
          Get the type of the property
 String getPropertyName()
          Get a name representative of this property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyedAccess

public KeyedAccess(Type containerType,
                   Object key)
Create a new KeyedAccess instance.

Parameters:
containerType -
key -
Method Detail

getJavaElementType

public static Type getJavaElementType(Type containerType)
Get the Java element type of a particular container type.

Parameters:
containerType -
Returns:
Type or null if containerType is not some kind of Map

get

public Object get(Object instance)
Get the value from the given instance.

Specified by:
get in class AccessStrategy
Returns:
the value

getElementType

public ElementType getElementType()
Get the Java program ElementType used by this AccessStrategy to determine property values.

Specified by:
getElementType in class AccessStrategy
Returns:
ElementType

getJavaType

public Type getJavaType()
Get the type of the property

Specified by:
getJavaType in class AccessStrategy
Returns:
Type

getPropertyName

public String getPropertyName()
Get a name representative of this property.

Specified by:
getPropertyName in class AccessStrategy
Returns:
String


Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.