类 ClassUtils


  • public class ClassUtils
    extends Object
    • 构造器详细资料

      • ClassUtils

        public ClassUtils()
    • 方法详细资料

      • getCallerClassLoader

        public static ClassLoader getCallerClassLoader​(Class<?> caller)
      • getClassLoader

        public static ClassLoader getClassLoader​(Class<?> clazz)
        get class loader
        参数:
        clazz -
        返回:
        class loader
      • getClassLoader

        public static ClassLoader getClassLoader()
        Return the default ClassLoader to use: typically the thread context ClassLoader, if available; the ClassLoader that loaded the ClassUtils class will be used as fallback.

        Call this method if you intend to use the thread context ClassLoader in a scenario where you absolutely need a non-null ClassLoader reference: for example, for class path resource loading (but not necessarily for Class.forName, which accepts a null ClassLoader reference as well).

        返回:
        the default ClassLoader (never null)
        另请参阅:
        Thread.getContextClassLoader()
      • resolvePrimitiveClassName

        public static Class<?> resolvePrimitiveClassName​(String name)
        Resolve the given class name as primitive class, if appropriate, according to the JVM's naming rules for primitive classes.

        Also supports the JVM's internal class names for primitive arrays. Does not support the "[]" suffix notation for primitive arrays; this is only supported by forName(java.lang.String).

        参数:
        name - the name of the potentially primitive class
        返回:
        the primitive class, or null if the name does not denote a primitive class or primitive array class
      • toShortString

        public static String toShortString​(Object obj)
      • simpleClassName

        public static String simpleClassName​(Class<?> clazz)
      • isPrimitive

        public static boolean isPrimitive​(Class<?> type)
        已过时。
        as 2.7.6, use Class.isPrimitive() plus isSimpleType(Class) instead
        The specified type is primitive type or simple type
        参数:
        type - the type to test
        返回:
      • isSimpleType

        public static boolean isSimpleType​(Class<?> type)
        The specified type is simple type or not
        参数:
        type - the type to test
        返回:
        if type is one element of SIMPLE_TYPES, return true, or false
        从以下版本开始:
        2.7.6
        另请参阅:
        SIMPLE_TYPES
      • convertPrimitive

        public static Object convertPrimitive​(Class<?> type,
                                              String value)
      • isTypeMatch

        public static boolean isTypeMatch​(Class<?> type,
                                          String value)
        We only check boolean value at this moment.
        参数:
        type -
        value -
        返回:
      • getAllSuperClasses

        public static Set<Class<?>> getAllSuperClasses​(Class<?> type,
                                                       Predicate<Class<?>>... classFilters)
        Get all super classes from the specified type
        参数:
        type - the specified type
        classFilters - the filters for classes
        返回:
        non-null read-only Set
        从以下版本开始:
        2.7.6
      • getAllInterfaces

        public static Set<Class<?>> getAllInterfaces​(Class<?> type,
                                                     Predicate<Class<?>>... interfaceFilters)
        Get all interfaces from the specified type
        参数:
        type - the specified type
        interfaceFilters - the filters for interfaces
        返回:
        non-null read-only Set
        从以下版本开始:
        2.7.6
      • getAllInheritedTypes

        public static Set<Class<?>> getAllInheritedTypes​(Class<?> type,
                                                         Predicate<Class<?>>... typeFilters)
        Get all inherited types from the specified type
        参数:
        type - the specified type
        typeFilters - the filters for types
        返回:
        non-null read-only Set
        从以下版本开始:
        2.7.6
      • isPresent

        public static boolean isPresent​(String className,
                                        ClassLoader classLoader)
        Test the specified class name is present in the ClassLoader
        参数:
        className - the name of Class
        classLoader - ClassLoader
        返回:
        If found, return true
        从以下版本开始:
        2.7.6
      • resolveClass

        public static Class<?> resolveClass​(String className,
                                            ClassLoader classLoader)
        Resolve the Class by the specified name and ClassLoader
        参数:
        className - the name of Class
        classLoader - ClassLoader
        返回:
        If can't be resolved , return null
        从以下版本开始:
        2.7.6
      • isGenericClass

        public static boolean isGenericClass​(Class<?> type)
        Is generic class or not?
        参数:
        type - the target type
        返回:
        if the target type is not null or void or Void.class, return true, or false
        从以下版本开始:
        2.7.6