public class TypeUtil extends Object
| Constructor and Description |
|---|
TypeUtil() |
| Modifier and Type | Method and Description |
|---|---|
static ParameterizedType |
createParameterizedType(Class<?> rawClass,
Type... genericTypes)
Create a parametrized type from a raw class and its type arguments.
|
static List<Class<?>> |
getAllClasses(Class<?> clazz)
Find all super classes including this class itself.
|
static Class<?> |
getRawClass(Type type)
Get the raw class for a given type.
|
static Type |
getSuperType(Type type)
Get the super type for a given type.
|
static Type |
getSuperType(Type subType,
Class<?> rawSuperType)
Get the super type for a type in its super type chain, which has
a raw class that matches the specified class.
|
static Type |
getTypeArgument(Type type)
Get the generic argument, or the first if the type has more than one.
|
static Type[] |
getTypeArguments(Type type)
Get the generic arguments for a type.
|
static boolean |
isTypeOrSubTypeOf(Type subType,
Type superType)
Determines if a type is the same or a subtype for another type.
|
public static List<Class<?>> getAllClasses(Class<?> clazz)
clazz - the raw class to find super types forpublic static Type[] getTypeArguments(Type type)
type - the type to get argumentspublic static Type getTypeArgument(Type type)
type - the type to get argumentspublic static Class<?> getRawClass(Type type)
type - the input typepublic static Type getSuperType(Type type)
type - the input typepublic static Type getSuperType(Type subType, Class<?> rawSuperType)
subType - the sub type to find super type forrawSuperType - the raw class for the super typepublic static boolean isTypeOrSubTypeOf(Type subType, Type superType)
subType - the supposed sub typesuperType - the supposed super typepublic static ParameterizedType createParameterizedType(Class<?> rawClass, Type... genericTypes)
rawClass - the raw class to construct the parametrized typegenericTypes - the generic arguments/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/