|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.core.convert.TypeDescriptor
public class TypeDescriptor
Context about a type to convert to.
Field Summary | |
---|---|
static TypeDescriptor |
NULL
Constant defining an 'unknown' TypeDescriptor |
Constructor Summary | |
---|---|
TypeDescriptor(Field field)
Create a new type descriptor for a field. |
|
TypeDescriptor(Field field,
Class<?> type)
Create a new type descriptor for a field. |
|
TypeDescriptor(MethodParameter methodParameter)
Create a new type descriptor from a method or constructor parameter. |
|
TypeDescriptor(MethodParameter methodParameter,
Class<?> type)
Create a new type descriptor from a method or constructor parameter. |
Method Summary | |
---|---|
String |
asString()
A textual representation of the type descriptor (eg. |
TypeDescriptor |
forElementType(Class<?> elementType)
Create a copy of this type descriptor, preserving the context information but exposing the specified element type (e.g. |
static TypeDescriptor |
forObject(Object object)
Create a new type descriptor for the class of the given object. |
Annotation |
getAnnotation(Class<? extends Annotation> annotationType)
Obtain the annotation associated with the wrapped parameter/field, if any. |
Annotation[] |
getAnnotations()
Obtain the annotations associated with the wrapped parameter/field, if any. |
Class<?> |
getElementType()
If this type is an array type or Collection type, returns the underlying element type. |
TypeDescriptor |
getElementTypeDescriptor()
Return the element type as a type descriptor. |
Field |
getField()
Return the wrapped Field, if any. |
Class<?> |
getMapKeyType()
Determine the generic key type of the wrapped Map parameter/field, if any. |
TypeDescriptor |
getMapKeyTypeDescriptor()
Returns map key type as a type descriptor. |
Class<?> |
getMapValueType()
Determine the generic value type of the wrapped Map parameter/field, if any. |
TypeDescriptor |
getMapValueTypeDescriptor()
Returns map value type as a type descriptor. |
MethodParameter |
getMethodParameter()
Return the wrapped MethodParameter, if any. |
String |
getName()
Returns the name of this type: the fully qualified class name. |
Class<?> |
getObjectType()
Determine the declared type of the wrapped parameter/field. |
Class<?> |
getType()
Determine the declared (non-generic) type of the wrapped parameter/field. |
boolean |
isArray()
Is this type an array type? |
boolean |
isAssignableTo(TypeDescriptor targetType)
Returns true if an object this type can be assigned to a reference of given targetType. |
boolean |
isCollection()
Is this type a Collection type? |
boolean |
isMap()
Is this type a Map type? |
boolean |
isMapEntryTypeKnown()
Is this descriptor for a map where the key type and value type are known? |
boolean |
isPrimitive()
Is this type a primitive type? |
String |
toString()
|
static TypeDescriptor |
valueOf(Class<?> type)
Create a new type descriptor for the given class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final TypeDescriptor NULL
Constructor Detail |
---|
public TypeDescriptor(MethodParameter methodParameter)
Use this constructor when a target conversion point originates from a method parameter, such as a setter method argument.
methodParameter
- the MethodParameter to wrappublic TypeDescriptor(Field field)
field
- the field to wrappublic TypeDescriptor(MethodParameter methodParameter, Class<?> type)
Use this constructor when a target conversion point originates from a method parameter, such as a setter method argument.
methodParameter
- the MethodParameter to wraptype
- the specific type to expose (may be an array/collection element)public TypeDescriptor(Field field, Class<?> type)
field
- the field to wrapMethod Detail |
---|
public MethodParameter getMethodParameter()
Note: Either MethodParameter or Field is available.
null
if nonepublic Field getField()
Note: Either MethodParameter or Field is available.
null
if nonepublic Class<?> getType()
NULL
.public Class<?> getObjectType()
public String getName()
public boolean isPrimitive()
public boolean isArray()
public boolean isCollection()
Collection
type?
public Class<?> getElementType()
Collection
type, returns the underlying element type.
Returns null
if the type is neither an array or collection.
public TypeDescriptor getElementTypeDescriptor()
public TypeDescriptor forElementType(Class<?> elementType)
elementType
- the desired type to expose
public boolean isMap()
Map
type?
public boolean isMapEntryTypeKnown()
public Class<?> getMapKeyType()
null
if nonepublic Class<?> getMapValueType()
null
if nonepublic TypeDescriptor getMapKeyTypeDescriptor()
public TypeDescriptor getMapValueTypeDescriptor()
public Annotation[] getAnnotations()
public Annotation getAnnotation(Class<? extends Annotation> annotationType)
public boolean isAssignableTo(TypeDescriptor targetType)
targetType
- the target type
public String asString()
public String toString()
toString
in class Object
public static TypeDescriptor valueOf(Class<?> type)
type
- the class
public static TypeDescriptor forObject(Object object)
object
- the object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |