Class ClassUtils


  • public final class ClassUtils
    extends Object
    • Field Detail

      • IS_ANDROID

        public static final boolean IS_ANDROID
    • Constructor Detail

      • ClassUtils

        public ClassUtils()
    • Method Detail

      • areNullSafeEquals

        public static boolean areNullSafeEquals​(Object obj1,
                                                Object obj2)
      • convertResourceToClassName

        public static String convertResourceToClassName​(String pResourceName)
        Please do not use - internal org/my/Class.xxx -> org.my.Class
      • convertClassToResourcePath

        public static String convertClassToResourcePath​(Class cls)
        Please do not use - internal org.my.Class -> org/my/Class.class
      • convertClassToResourcePath

        public static String convertClassToResourcePath​(String pName)
      • stripExtension

        public static String stripExtension​(String pResourceName)
        Please do not use - internal org/my/Class.xxx -> org/my/Class
      • toJavaCasing

        public static String toJavaCasing​(String pName)
      • clazzName

        public static String clazzName​(File base,
                                       File file)
      • canonicalName

        public static String canonicalName​(Class clazz)
      • loadClass

        public static Class<?> loadClass​(String className,
                                         ClassLoader classLoader)
        This method will attempt to load the specified Class. It uses a syncrhonized HashMap to cache the reflection Class lookup.
      • instantiateObject

        public static Object instantiateObject​(String className)
      • instantiateObject

        public static Object instantiateObject​(String className,
                                               ClassLoader classLoader)
        This method will attempt to create an instance of the specified Class. It uses a syncrhonized HashMap to cache the reflection Class lookup.
      • instantiateObject

        public static Object instantiateObject​(String className,
                                               ClassLoader classLoader,
                                               Object... args)
        This method will attempt to create an instance of the specified Class. It uses a synchronized HashMap to cache the reflection Class lookup. It will execute the default constructor with the passed in arguments
        Parameters:
        className - the name of the class
        args - arguments to default constructor
      • instantiateObject

        public static Object instantiateObject​(String className,
                                               Object... args)
        This method will attempt to create an instance of the specified Class. It uses a synchronized HashMap to cache the reflection Class lookup. It will execute the default constructor with the passed in arguments
        Parameters:
        className - teh name of the class
        args - arguments to default constructor
      • addImportStylePatterns

        public static void addImportStylePatterns​(Map<String,​Object> patterns,
                                                  String str)
        Populates the import style pattern map from give comma delimited string
      • isMatched

        public static boolean isMatched​(Map<String,​Object> patterns,
                                        String className)
        Determines if a given full qualified class name matches any import style patterns.
      • getPackage

        public static String getPackage​(Class<?> cls)
        Extracts the package name from the given class object
      • getAccessibleProperties

        public static List<String> getAccessibleProperties​(Class<?> clazz)
      • getAccessor

        public static Method getAccessor​(Class<?> clazz,
                                         String field,
                                         boolean exceptionIfIncompatible)
      • isReadableProperty

        public static boolean isReadableProperty​(Class clazz,
                                                 String property)
      • getFieldOrAccessor

        public static Member getFieldOrAccessor​(Class clazz,
                                                String property)
      • getGetterMethod

        public static Method getGetterMethod​(Class clazz,
                                             String property)
      • getGetterMethod

        public static String getGetterMethod​(String s)
      • extractGenericType

        public static Class extractGenericType​(Class<?> clazz,
                                               String methodName)
      • isTypeCompatibleWithArgumentType

        public static boolean isTypeCompatibleWithArgumentType​(Class<?> actual,
                                                               Class<?> formal)
      • isAssignable

        public static boolean isAssignable​(Class<?> type,
                                           Object obj)
      • isConvertible

        public static boolean isConvertible​(Class<?> srcPrimitive,
                                            Class<?> tgtPrimitive)
      • isFinal

        public static boolean isFinal​(Class<?> clazz)
      • isInterface

        public static boolean isInterface​(Class<?> clazz)
      • getter2property

        public static String getter2property​(String methodName)
      • setter2property

        public static String setter2property​(String methodName)
      • isGetter

        public static boolean isGetter​(String methodName)
      • isSetter

        public static boolean isSetter​(String methodName)
      • deepClone

        public static <T extends Externalizable> T deepClone​(T origin)
      • convertFromPrimitiveType

        public static Class<?> convertFromPrimitiveType​(Class<?> type)
      • convertToPrimitiveType

        public static Class<?> convertToPrimitiveType​(Class<?> type)
      • convertPrimitiveNameToType

        public static Class<?> convertPrimitiveNameToType​(String typeName)
      • getAllImplementedInterfaceNames

        public static Set<Class<?>> getAllImplementedInterfaceNames​(Class<?> klass)
      • getMinimalImplementedInterfaceNames

        public static Set<Class<?>> getMinimalImplementedInterfaceNames​(Class<?> klass)
      • isCaseSenstiveOS

        public static boolean isCaseSenstiveOS()
      • isWindows

        public static boolean isWindows()
      • isOSX

        public static boolean isOSX()
      • isJboss

        public static boolean isJboss()
      • isAndroid

        public static boolean isAndroid()
        Checks if running on Android operating system
      • findCommonSuperClass

        public static Class<?> findCommonSuperClass​(Class<?> c1,
                                                    Class<?> c2)
      • getSimpleName

        public static String getSimpleName​(Class<?> c)
      • getCanonicalSimpleName

        public static String getCanonicalSimpleName​(Class<?> c)
      • getCanonicalSimpleName

        public static String getCanonicalSimpleName​(Class<?> c,
                                                    char separator)