public class ReflectionUtils extends Object
| Constructor | Description |
|---|---|
ReflectionUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static <T> T |
createNoArgConstructorInstance(Class<T> clazz) |
Search for no argument constructor of a class and create instance.
|
static ParameterizedType |
findParameterizedType(Class<?> classToSearch,
Class<?> parameterizedInterface) |
For generic adapters like:
|
static Optional<Class<?>> |
getOptionalRawType(Type type) |
Get raw type by type.
|
static Class<?> |
getRawType(Type type) |
Get raw type by type.
|
static boolean |
isResolvedType(Type type) |
Check if type needs resolution.
|
static Type |
resolveItemVariableType(RuntimeTypeInfo item,
TypeVariable<?> typeVariable) |
Resolve a bounded type variable type by its wrapper types.
|
static Optional<Type> |
resolveOptionalType(RuntimeTypeInfo info,
Type type) |
|
static Class<?> |
resolveRawType(RuntimeTypeInfo item,
Type type) |
Get a raw type of any type.
|
static Type |
resolveType(RuntimeTypeInfo item,
Type type) |
Resolve a type by item.
|
static Type |
resolveTypeArguments(ParameterizedType typeToResolve,
Type typeToSearch) |
Resolves
TypeVariable arguments of generic types. |
public static Optional<Class<?>> getOptionalRawType(Type type)
type - Type to get class information from, not null.public static Class<?> getRawType(Type type)
type - Type to get class information from, not null.public static Class<?> resolveRawType(RuntimeTypeInfo item, Type type)
TypeVariable recursively search AbstractItem for resolution of typevar.
If type is a WildcardType find most specific upper / lower bound, which can be used. If most specific
bound is a TypeVariable, perform typevar resolution.item - item containing wrapper class of a type field, not null.type - type to resolve, typically field type or generic bound, not null.public static Type resolveType(RuntimeTypeInfo item, Type type)
TypeVariable recursively search AbstractItem for resolution of typevar.
If type is a WildcardType find most specific upper / lower bound, which can be used. If most specific
bound is a TypeVariable, perform typevar resolution.item - item containing wrapper class of a type field, not null.type - type to resolve, typically field type or generic bound, not null.public static Optional<Type> resolveOptionalType(RuntimeTypeInfo info, Type type)
public static Type resolveItemVariableType(RuntimeTypeInfo item, TypeVariable<?> typeVariable)
item - item to search "runtime" generic type of a TypeVariable.typeVariable - type to search in item for, not null.public static Type resolveTypeArguments(ParameterizedType typeToResolve, Type typeToSearch)
TypeVariable arguments of generic types.typeToResolve - type to resolvetypeToSearch - type to searchpublic static <T> T createNoArgConstructorInstance(Class<T> clazz)
T - type of instanceclazz - not nullpublic static ParameterizedType findParameterizedType(Class<?> classToSearch, Class<?> parameterizedInterface)
interface ContainerAdapter<T> extends JsonbAdapter<Box<T>, Crate<T>>...;
class IntegerBoxToCrateAdapter implements ContainerAdapter<Integer>...;
classToSearch - class to resolve parameterized interfaceparameterizedInterface - interface to searchpublic static boolean isResolvedType(Type type)
type - Type to check.Copyright © 2018 Oracle Corporation. All rights reserved.