public class Types extends Object
Constructor and Description |
---|
Types() |
Modifier and Type | Method and Description |
---|---|
static void |
addConvertibleType(Class<?> type) |
static void |
addEnumType(Class<?> type) |
static Object |
getDefault(Class<?> type)
Returns the default value for this Java type (e.g.
|
static boolean |
isCloneable(Class<?> type)
Returns true if the Java type implements the
Cloneable interface. |
static boolean |
isConstructable(Class<?> type)
Returns true if the objects of this class are constructable.
|
static boolean |
isConstructable(Class<?> type,
boolean allowAbstractOrInterface)
Returns true if the objects of this class are constructable.
|
static boolean |
isConvertibleType(Class<?> type) |
static boolean |
isEnumType(Class<?> type) |
static boolean |
isImmutable(Class<?> type)
Returns true if the Java type is immutable.
|
static boolean |
isPrimitiveType(Class<?> type)
Returns true if the Java type is represented as a primitive type.
|
static boolean |
isSerializable(Class<?> type)
Returns true if the Java type implements the
Serializable
interface. |
static boolean |
isSimpleType(Class<?> type)
Returns true if the Java type is represented as a simple type.
|
static Object |
newInstance(Class<?> type)
Constructs a new object from the given class.
|
static Object |
newInstance(Class<?> type,
Object[] args)
Constructs a new object from the given class.
|
static Class<?> |
typeFromName(ClassLoader loader,
String typeName)
Returns the class name based on the supplied type name.
|
static Class<?> |
typeFromPrimitive(Class<?> type)
Maps from a primitive Java type to a Java class.
|
public static Class<?> typeFromName(ClassLoader loader, String typeName) throws ClassNotFoundException
loader
- The class loader to use, may be nulltypeName
- The type nameClassNotFoundException
- The specified class could not be foundpublic static Object getDefault(Class<?> type)
type
- The Java typepublic static Class<?> typeFromPrimitive(Class<?> type)
From To -------------- --------------- Boolean.TYPE Boolean.class Byte.TYPE Byte.class Character.TYPE Character.class Short.TYPE Short.class Integer.TYPE Integer.class Long.TYPE Long.class Float.TYPE Float.class Double.TYPE Double.class
type
- The Java type (primitive or not)public static boolean isSimpleType(Class<?> type)
type
- The Java typepublic static boolean isPrimitiveType(Class<?> type)
type
- The Java typepublic static void addEnumType(Class<?> type)
public static boolean isEnumType(Class<?> type)
public static void addConvertibleType(Class<?> type)
public static boolean isConvertibleType(Class<?> type)
public static Object newInstance(Class<?> type) throws IllegalStateException
type
- The class type of the object instance to be constructed.IllegalStateException
- The Java object cannot be constructedpublic static Object newInstance(Class<?> type, Object[] args) throws IllegalStateException
type
- The class type of the object instance to be constructed.args
- Arguments to be supplied to constructor call.IllegalStateException
- The Java object cannot be constructedpublic static boolean isConstructable(Class<?> type)
type
- The Java typepublic static boolean isConstructable(Class<?> type, boolean allowAbstractOrInterface)
allowAbstractOrInterface
- True to indicate that abstract classes of interfaces are
allowed.type
- The Java typepublic static boolean isSerializable(Class<?> type)
Serializable
interface.type
- The Java typepublic static boolean isImmutable(Class<?> type)
type
- The Java typeCopyright © 2019. All rights reserved.