public class TypeUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static BigDecimal |
DEC_HIGH |
static BigDecimal |
DEC_LOW |
static BigInteger |
INT_HIGH |
static BigInteger |
INT_LOW |
| 构造器和说明 |
|---|
TypeUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Collection |
createCollection(Type type,
boolean isThrow) |
static EnumWrap |
createEnum(Class<?> clz) |
static Map |
createMap(Type type) |
static Type |
getCollectionItemType(Type fieldType) |
static Map<TypeVariable,Type> |
getGenericInfo(Type type)
获取泛型变量和泛型实际类型的对应关系Map
|
static Class<?> |
getRawClass(Type type) |
static Object |
strTo(String str,
Class<?> clz)
将字符串转为类型
|
static ParameterizedType |
toParameterizedType(Type type)
将
Type 转换为ParameterizedTypeParameterizedType用于获取当前类或父类中泛型参数化后的类型一般用于获取泛型参数具体的参数类型,例如: class A<T> class B extends A<String> 通过此方法,传入B.class即可得到B ParameterizedType,从而获取到String |
public static final BigInteger INT_LOW
public static final BigInteger INT_HIGH
public static final BigDecimal DEC_LOW
public static final BigDecimal DEC_HIGH
public static Collection createCollection(Type type, boolean isThrow)
public static ParameterizedType toParameterizedType(Type type)
Type 转换为ParameterizedTypeParameterizedType用于获取当前类或父类中泛型参数化后的类型class A<T> class B extends A<String>
通过此方法,传入B.class即可得到BParameterizedType,从而获取到String
type - TypeParameterizedTypepublic static Map<TypeVariable,Type> getGenericInfo(Type type)
type - 被解析的包含泛型参数的类Copyright © 2021. All rights reserved.