moved static factory methods up
This commit is contained in:
parent
d6f4f4c7b4
commit
39325958bc
|
|
@ -354,6 +354,32 @@ public class TypeDescriptor {
|
||||||
return isTypeAssignableTo(targetType.getType());
|
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
|
// internal helpers
|
||||||
|
|
||||||
private Class<?> getArrayComponentType() {
|
private Class<?> getArrayComponentType() {
|
||||||
|
|
@ -438,32 +464,5 @@ public class TypeDescriptor {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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…
Reference in New Issue