public final class Classes
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static @Nullable java.lang.reflect.Type |
arrayComponentType(java.lang.reflect.Type type)
Returns the array type of the given
type. |
static void |
checkRetention(@NotNull java.lang.Class<? extends java.lang.annotation.Annotation> type)
Checks whether the given annotation type has
Retention
of RetentionPolicy.RUNTIME. |
static java.lang.reflect.Type |
getFirstGeneric(@NotNull java.lang.Class<?> cl,
@NotNull java.lang.reflect.Type fallback)
Deprecated.
Classes do not have generics. You might have passed
the wrong parameters.
|
static java.lang.reflect.Type |
getFirstGeneric(@NotNull java.lang.reflect.Type genericType,
@NotNull java.lang.reflect.Type fallback)
Returns the first generic type of the given (possibly parameterized)
type
genericType. |
static java.lang.Class<?> |
getRawType(java.lang.reflect.Type type)
Returns the
Class object representing the class or interface
that declared this type. |
static java.lang.Class<?> |
getType(@NotNull java.lang.Object o)
Returns the type of the given object
|
static boolean |
isClassPresent(@NotNull java.lang.String name)
Tests whether the given class is available or not
|
static boolean |
isWrapperType(java.lang.Class<?> type)
Returns
true if the specified type is one of the nine
primitive-wrapper types, such as Integer. |
static <T> java.lang.Class<T> |
unwrap(java.lang.Class<T> type)
Returns the corresponding primitive type of
type if it is a wrapper type; otherwise
returns the type itself. |
static <T> java.lang.Class<T> |
wrap(java.lang.Class<T> type)
Returns the corresponding wrapper type of
type if it is a primitive type; otherwise
returns the type itself. |
public static java.lang.Class<?> getType(@NotNull
@NotNull java.lang.Object o)
o - Object to get forpublic static <T> java.lang.Class<T> wrap(java.lang.Class<T> type)
type if it is a primitive type; otherwise
returns the type itself.
wrap(int.class) == Integer.class
wrap(Integer.class) == Integer.class
wrap(String.class) == String.class
@Nullable public static @Nullable java.lang.reflect.Type arrayComponentType(java.lang.reflect.Type type)
type. This
will respect generics of the array type.type - The type to parse fromnull if it does
not represent an array.public static <T> java.lang.Class<T> unwrap(java.lang.Class<T> type)
type if it is a wrapper type; otherwise
returns the type itself.
unwrap(Integer.class) == int.class
unwrap(int.class) == int.class
unwrap(String.class) == String.class
public static boolean isWrapperType(java.lang.Class<?> type)
true if the specified type is one of the nine
primitive-wrapper types, such as Integer.type - Type to checkClass.isPrimitive()public static java.lang.Class<?> getRawType(java.lang.reflect.Type type)
Class object representing the class or interface
that declared this type.Class object representing the class or interface
that declared this type@Deprecated
@Contract(value="_,_ -> param2")
public static java.lang.reflect.Type getFirstGeneric(@NotNull
@NotNull java.lang.Class<?> cl,
@NotNull
@NotNull java.lang.reflect.Type fallback)
type
argument, and meant to invoke getFirstGeneric(Type, Type) instead.cl - The class. This parameter is ignoredfallback - The fallback to returngetFirstGeneric(Type, Type)public static java.lang.reflect.Type getFirstGeneric(@NotNull
@NotNull java.lang.reflect.Type genericType,
@NotNull
@NotNull java.lang.reflect.Type fallback)
genericType. If the type is not parameterized,
this will return fallback.genericType - The generic typefallback - The fallback to returnpublic static boolean isClassPresent(@NotNull
@NotNull java.lang.String name)
name - Class name to testpublic static void checkRetention(@NotNull
@NotNull java.lang.Class<? extends java.lang.annotation.Annotation> type)
Retention
of RetentionPolicy.RUNTIME. This helps catch user errors where a
certain annotation is being checked for, that may have been omitted
because it does not have a runtime retention policy.type - Annotation to check