public final class Class<T> extends Object
Constructor and Description |
---|
Class() |
Modifier and Type | Method and Description |
---|---|
Class |
asSubclass(Class superclass)
Replacement for Class.asSubclass(Class).
|
Object |
cast(Object object)
Replacement for Class.cast(Object).
|
static Class |
forName(String className)
Deprecated.
don't use this method for anything important since class names are obfuscated on the device!
|
<T extends Annotation> |
getAnnotation(Class annotationType)
Returns this element's annotation for the specified type if such an annotation is present, else null.
|
Annotation[] |
getAnnotations()
Returns all annotations present on this element.
|
String |
getCanonicalName()
Deprecated.
don't use this method for anything important since class names are obfuscated on the device!
|
Annotation[] |
getDeclaredAnnotations()
Returns all annotations that are directly present on this element.
|
String |
getName()
Deprecated.
don't use this method for anything important since class names are obfuscated on the device!
|
String |
getSimpleName()
Deprecated.
don't use this method for anything important since class names are obfuscated on the device!
|
boolean |
isAnnotation() |
boolean |
isAnnotationPresent(Class annotationType)
Returns true if an annotation for the specified type is present on this element, else false.
|
boolean |
isAnonymousClass()
replacement for Class.isAnonymousClass()
|
boolean |
isArray()
Determines if this Class object represents an array class.
|
boolean |
isAssignableFrom(Class cls)
Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter.
|
boolean |
isEnum()
Replacement for Class.isEnum().
|
boolean |
isInstance(Object obj)
Determines if the specified Object is assignment-compatible with the object represented by this Class.
|
boolean |
isInterface()
Determines if the specified Class object represents an interface type.
|
boolean |
isSynthetic()
replacement for Class.isSynthetic()
|
Object |
newInstance()
Creates a new instance of a class.
|
String |
toString()
Converts the object to a string.
|
public static Class forName(String className) throws ClassNotFoundException
ClassNotFoundException
public String getName()
public boolean isArray()
public boolean isAssignableFrom(Class cls)
public boolean isInstance(Object obj)
public boolean isInterface()
public Object newInstance() throws InstantiationException, IllegalAccessException
public String toString()
public boolean isAnnotation()
public <T extends Annotation> T getAnnotation(Class annotationType)
public Annotation[] getAnnotations()
public Annotation[] getDeclaredAnnotations()
public boolean isAnnotationPresent(Class annotationType)
public Class asSubclass(Class superclass)
c
- a Classsuperclass
- another Class which must be a superclass of cClassCastException
- if c ispublic Object cast(Object object)
c
- Class we want to cast obj toobject
- object we want to castnull
if the object is
null
.ClassCastException
- if obj is not
null
or an instance of cpublic boolean isEnum()
class_
- class we want to test.public boolean isAnonymousClass()
public String getSimpleName()
public boolean isSynthetic()
public String getCanonicalName()