moved static factory methods up

master
Keith Donald 15 years ago
parent d6f4f4c7b4
commit 39325958bc
  1. 53
      org.springframework.core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

@ -354,6 +354,32 @@ public class TypeDescriptor {
return isTypeAssignableTo(targetType.getType());
}
// static factory methods
/**
* Creates a new type descriptor for the given class.
* @param type the class
* @return the type descriptor
*/
public static TypeDescriptor valueOf(Class<?> type) {
if (type == null) {
return TypeDescriptor.NULL;
} else if (type.equals(String.class)) {
return TypeDescriptor.STRING;
} else {
return new TypeDescriptor(type);
}
}
/**
* Creates a new type descriptor for the class of the given object.
* @param object the object
* @return the type descriptor
*/
public static TypeDescriptor forObject(Object object) {
return (object == null ? NULL : valueOf(object.getClass()));
}
// internal helpers
private Class<?> getArrayComponentType() {
@ -439,31 +465,4 @@ public class TypeDescriptor {
}
}
// static factory methods
/**
* Creates a new type descriptor for the given class.
* @param type the class
* @return the type descriptor
*/
public static TypeDescriptor valueOf(Class<?> type) {
if (type == null) {
return TypeDescriptor.NULL;
} else if (type.equals(String.class)) {
return TypeDescriptor.STRING;
} else {
return new TypeDescriptor(type);
}
}
/**
* Creates a new type descriptor for the class of the given object.
* @param object the object
* @return the type descriptor
*/
public static TypeDescriptor forObject(Object object) {
return (object == null ? NULL : valueOf(object.getClass()));
}
}

Loading…
Cancel
Save