public final class TypeArgumentsExtensions extends Object
TypeArgumentsExtensions is a utility class for getting the type arguments from
a child class that extended a generic base class. | Constructor and Description |
|---|
TypeArgumentsExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static Class<?> |
getClass(Type type)
Get the underlying class for a type, or null if the type is a variable type.
|
static <T> Class<?> |
getFirstTypeArgument(Class<? extends T> childClass)
Gets the first type argument from the childClass.
|
static <T> Class<?> |
getFirstTypeArgument(Class<T> baseClass,
Class<? extends T> childClass)
Gets the first type argument from the childClass.
|
static <T> Class<?> |
getTypeArgument(Class<? extends T> childClass,
int index)
Gets the type argument from the childClass at the given index or null if it does not exists.
|
static <T> Class<?> |
getTypeArgument(Class<T> baseClass,
Class<? extends T> childClass,
int index)
Gets the type argument from the childClass at the given index or null if it does not exists.
|
static <T> List<Class<?>> |
getTypeArguments(Class<? extends T> childClass)
Get the actual type arguments from the given child class.
|
static <T> List<Class<?>> |
getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
Get the actual type arguments a child class has used to extend a generic base class.
|
static Map<Type,Type> |
getTypeArgumentsAndParameters(ParameterizedType parameterizedType)
Gets the type arguments and parameters.
|
public static Class<?> getClass(@NonNull Type type)
type - the typepublic static <T> Class<?> getFirstTypeArgument(@NonNull Class<? extends T> childClass)
T - the generic type of the baseClasschildClass - the child classpublic static <T> Class<?> getFirstTypeArgument(@NonNull Class<T> baseClass, @NonNull Class<? extends T> childClass)
T - the generic type of the baseClassbaseClass - the base classchildClass - the child classpublic static <T> Class<?> getTypeArgument(@NonNull Class<? extends T> childClass, int index)
T - the generic type of the baseClasschildClass - the child classindex - the index of the type argumentpublic static <T> Class<?> getTypeArgument(@NonNull Class<T> baseClass, @NonNull Class<? extends T> childClass, int index)
T - the generic type of the baseClassbaseClass - the base classchildClass - the child classindex - the index of the type argumentpublic static <T> List<Class<?>> getTypeArguments(@NonNull Class<? extends T> childClass)
T - the generic type of the baseClasschildClass - the child classpublic static <T> List<Class<?>> getTypeArguments(@NonNull Class<T> baseClass, @NonNull Class<? extends T> childClass)
T - the generic type of the baseClassbaseClass - the base classchildClass - the child classpublic static Map<Type,Type> getTypeArgumentsAndParameters(@NonNull ParameterizedType parameterizedType)
parameterizedType - the parameterized typeCopyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.