程序包 dev.utils.common

类 ClassUtils

java.lang.Object
dev.utils.common.ClassUtils

public final class ClassUtils extends Object
detail: 类 ( Class ) 工具类
作者:
Ttt
  • 方法详细资料

    • newInstance

      public static <T> T newInstance(Class<T> clazz)
      根据类获取对象, 不再必须一个无参构造
      类型参数:
      T - 泛型
      参数:
      clazz - Class
      返回:
      初始化后的对象
    • getDefaultPrimitiveValue

      public static Object getDefaultPrimitiveValue(Class<?> clazz)
      获取 Class 原始类型值
      参数:
      clazz - Class
      返回:
      原始类型值
    • getClass

      public static Class<?> getClass(Object object)
      获取 Object Class
      参数:
      object - Object
      返回:
      Object Class
    • getClass

      public static Class<?> getClass(Type type)
      获取 Type Class
      参数:
      type - Type
      返回:
      Type Class
    • isPrimitive

      public static boolean isPrimitive(Class<?> clazz)
      判断 Class 是否为原始类型
      参数:
      clazz - Class
      返回:
      true yes, false no
    • isCollection

      public static boolean isCollection(Class<?> clazz)
      判断是否 Collection 类型
      参数:
      clazz - Class
      返回:
      true yes, false no
    • isMap

      public static boolean isMap(Class<?> clazz)
      判断是否 Map 类型
      参数:
      clazz - Class
      返回:
      true yes, false no
    • isArray

      public static boolean isArray(Class<?> clazz)
      判断是否 Array 类型
      参数:
      clazz - Class
      返回:
      true yes, false no
    • isGenericParamType

      public static boolean isGenericParamType(Type type)
      判断是否参数类型
      参数:
      type - Type
      返回:
      true yes, false no
    • getGenericParamType

      public static Type getGenericParamType(Type type)
      获取参数类型
      参数:
      type - Type
      返回:
      Type
    • getGenericSuperclass

      public static Type getGenericSuperclass(Object object)
      获取父类泛型类型
      参数:
      object - Object
      返回:
      泛型类型
    • getGenericSuperclass

      public static Type getGenericSuperclass(Object object, int pos)
      获取父类泛型类型
      参数:
      object - Object
      pos - 泛型参数索引
      返回:
      泛型类型
    • getGenericSuperclass

      public static Type getGenericSuperclass(Class<?> clazz)
      获取父类泛型类型
      参数:
      clazz - Class
      返回:
      泛型类型
    • getGenericSuperclass

      public static Type getGenericSuperclass(Class<?> clazz, int pos)
      获取父类泛型类型
      参数:
      clazz - Class
      pos - 泛型参数索引
      返回:
      泛型类型
    • getGenericInterfaces

      public static Type getGenericInterfaces(Object object, Class<?> interfaceClazz)
      获取接口泛型类型
      参数:
      object - Object
      interfaceClazz - 接口 Class
      返回:
      泛型类型
    • getGenericInterfaces

      public static Type getGenericInterfaces(Object object, Class<?> interfaceClazz, int pos)
      获取接口泛型类型
      参数:
      object - Object
      interfaceClazz - 接口 Class
      pos - 泛型参数索引
      返回:
      泛型类型
    • getGenericInterfaces

      public static Type getGenericInterfaces(Class<?> clazz, Class<?> interfaceClazz)
      获取接口泛型类型
      参数:
      clazz - Class
      interfaceClazz - 接口 Class
      返回:
      泛型类型
    • getGenericInterfaces

      public static Type getGenericInterfaces(Class<?> clazz, Class<?> interfaceClazz, int pos)
      获取接口泛型类型
      参数:
      clazz - Class
      interfaceClazz - 接口 Class
      pos - 泛型参数索引
      返回:
      泛型类型