|
|||||||||
| 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 a TypeDescriptor for a null value |
| Constructor Summary | |
|---|---|
protected |
TypeDescriptor(Class<?> nestedType,
MethodParameter methodParameter)
|
|
TypeDescriptor(Field field)
Create a new type descriptor for a field. |
|
TypeDescriptor(MethodParameter methodParameter)
Create a new type descriptor from a method or constructor parameter. |
| Method Summary | |
|---|---|
TypeDescriptor |
applyIndexedObject(Object object)
Create a copy of this nested type descriptor and apply the specific type information from the indexed object. |
String |
asString()
A textual representation of the type descriptor (eg. |
boolean |
equals(Object obj)
|
static TypeDescriptor |
forNestedType(Class<?> nestedType,
MethodParameter methodParameter)
Create a new type descriptor for a nested type declared on an array, collection, or map-based method parameter. |
static TypeDescriptor |
forNestedType(MethodParameter methodParameter)
Create a new type descriptor for a nested type declared on an array, collection, or map-based method parameter. |
static TypeDescriptor |
forObject(Object object)
Create a new type descriptor for an 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. |
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()
Exposes the underlying MethodParameter providing context for this TypeDescriptor. |
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. |
int |
hashCode()
|
boolean |
isArray()
Is this type an array type? |
boolean |
isAssignableTo(TypeDescriptor targetType)
Returns true if an object of 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 |
isPrimitive()
Is this type a primitive type? |
protected TypeDescriptor |
newNestedTypeDescriptor(Class<?> nestedType,
MethodParameter nested)
|
protected Annotation[] |
resolveAnnotations()
|
protected static Class<?> |
resolveNestedType(MethodParameter methodParameter)
|
String |
toString()
|
static TypeDescriptor |
valueOf(Class<?> type)
Create a new type descriptor for the given class. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final TypeDescriptor NULL
null value
| Constructor Detail |
|---|
public TypeDescriptor(MethodParameter methodParameter)
methodParameter - the MethodParameter to wrappublic TypeDescriptor(Field field)
field - the field to wrap
protected TypeDescriptor(Class<?> nestedType,
MethodParameter methodParameter)
| Method Detail |
|---|
public static TypeDescriptor valueOf(Class<?> type)
forObject(Object) for constructing source type descriptors for source objects.
type - the class
public static TypeDescriptor forObject(Object object)
NULL.
If the object is not a collection, simply calls valueOf(Class).
If the object is a collection, this factory method will derive the element type(s) by introspecting the collection.
object - the source object
ConversionService.convert(Object, Class),
CollectionUtils.findCommonElementType(Collection)public static TypeDescriptor forNestedType(MethodParameter methodParameter)
methodParameter - the method parameter declaring the collection or map
public static TypeDescriptor forNestedType(Class<?> nestedType,
MethodParameter methodParameter)
nestedType - the nested typemethodParameter - the method parameter declaring the collection or map
public Class<?> getType()
null if this is NULLpublic Class<?> getObjectType()
public String getName()
public boolean isPrimitive()
public Annotation[] getAnnotations()
public Annotation getAnnotation(Class<? extends Annotation> annotationType)
public boolean isAssignableTo(TypeDescriptor targetType)
targetType - the target type
public String asString()
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 boolean isMap()
Map type?
public Class<?> getMapKeyType()
null if nonepublic TypeDescriptor getMapKeyTypeDescriptor()
public Class<?> getMapValueType()
null if nonepublic TypeDescriptor getMapValueTypeDescriptor()
public MethodParameter getMethodParameter()
public TypeDescriptor applyIndexedObject(Object object)
public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectprotected Annotation[] resolveAnnotations()
protected TypeDescriptor newNestedTypeDescriptor(Class<?> nestedType,
MethodParameter nested)
protected static Class<?> resolveNestedType(MethodParameter methodParameter)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||