public enum GenericReflection extends Enum<GenericReflection>
This enum serves as a utility class for obtaining generic type information of methods and classes at runtime. This is especially useful for reflective operations that deal with generic types, as Java utilizes type erasure.
Note: This is an enum with a single instance (a singleton), but used purely as a namespace for utility methods, and cannot be instantiated.
| Modifier and Type | Method and Description |
|---|---|
static Class<?> |
erase(Type type)
Obtains the raw type representation of the specified generic type.
|
static Set<Type> |
getMethodReturnTypes(Type type)
Obtains the return types of all the methods in the specified type.
|
static Type[] |
getParameterTypes(Method method,
Type type)
Obtains the parameter types of the specified method with generic type information.
|
static Type |
getReturnType(Method method,
Type type)
Obtains the return type of the specified method as defined by a class or interface.
|
static GenericReflection |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static GenericReflection[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static GenericReflection[] values()
for (GenericReflection c : GenericReflection.values()) System.out.println(c);
public static GenericReflection valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static Set<Type> getMethodReturnTypes(Type type)
type - the Type to scan for methods.Type representing the return types of methods found in the specified type.UnsupportedOperationException - if the provided type is not a Class or ParameterizedType.public static Type getReturnType(Method method, Type type)
public static Type[] getParameterTypes(Method method, Type type)
Copyright © 2024. All rights reserved.