Package org.drools.core.util
Class ClassUtils
- java.lang.Object
-
- org.drools.core.util.ClassUtils
-
public final class ClassUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
IS_ANDROID
-
Constructor Summary
Constructors Constructor Description ClassUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Integer>
accessorPriorityMap(String field)
static void
addImportStylePatterns(Map<String,Object> patterns, String str)
Populates the import style pattern map from give comma delimited stringstatic boolean
areNullSafeEquals(Object obj1, Object obj2)
static String
canonicalName(Class clazz)
static String
clazzName(File base, File file)
static String
convertClassToResourcePath(Class cls)
Please do not use - internal org.my.Class -> org/my/Class.classstatic String
convertClassToResourcePath(String pName)
static Class<?>
convertFromPrimitiveType(Class<?> type)
static Class<?>
convertPrimitiveNameToType(String typeName)
static String
convertResourceToClassName(String pResourceName)
Please do not use - internal org/my/Class.xxx -> org.my.Classstatic Class<?>
convertToPrimitiveType(Class<?> type)
static <T extends Externalizable>
TdeepClone(T origin)
static <T extends Externalizable>
TdeepClone(T origin, ClassLoader classLoader)
static <T extends Externalizable>
TdeepClone(T origin, ClassLoader classLoader, Map<String,Object> cloningResources)
static Class
extractGenericType(Class<?> clazz, String methodName)
static Class<?>
findClass(String className, ClassLoader cl)
static Class<?>
findClass(String name, Collection<String> availableImports, ClassLoader cl)
static Class<?>
findCommonSuperClass(Class<?> c1, Class<?> c2)
static List<String>
getAccessibleProperties(Class<?> clazz)
static Method
getAccessor(Class<?> clazz, String field)
static Method
getAccessor(Class<?> clazz, String field, boolean exceptionIfIncompatible)
static Set<Class<?>>
getAllImplementedInterfaceNames(Class<?> klass)
static String
getCanonicalSimpleName(Class<?> c)
static String
getCanonicalSimpleName(Class<?> c, char separator)
static Class<?>
getClassFromName(String className)
static Class<?>
getClassFromName(String className, boolean initialize, ClassLoader classLoader)
static Field
getField(Class<?> clazz, String field)
static Member
getFieldOrAccessor(Class clazz, String property)
static Method
getGetterMethod(Class clazz, String property)
static String
getGetterMethod(String s)
static Set<Class<?>>
getMinimalImplementedInterfaceNames(Class<?> klass)
static String
getPackage(Class<?> cls)
Extracts the package name from the given class objectstatic Method
getSetter(Class<?> clazz, String field, Class<?> parameterType)
static String
getSimpleName(Class<?> c)
static String
getter2property(String methodName)
static Object
instantiateObject(String className)
static Object
instantiateObject(String className, ClassLoader classLoader)
This method will attempt to create an instance of the specified Class.static Object
instantiateObject(String className, ClassLoader classLoader, Object... args)
This method will attempt to create an instance of the specified Class.static Object
instantiateObject(String className, Object... args)
This method will attempt to create an instance of the specified Class.static boolean
isAndroid()
Checks if running on Android operating systemstatic boolean
isAssignable(Class<?> type, Object obj)
static boolean
isCaseSenstiveOS()
static boolean
isConvertible(Class<?> srcPrimitive, Class<?> tgtPrimitive)
static boolean
isFinal(Class<?> clazz)
static boolean
isGetter(String methodName)
static boolean
isInterface(Class<?> clazz)
static boolean
isJboss()
static boolean
isMatched(Map<String,Object> patterns, String className)
Determines if a given full qualified class name matches any import style patterns.static boolean
isOSX()
static boolean
isReadableProperty(Class clazz, String property)
static boolean
isSetter(String methodName)
static boolean
isTypeCompatibleWithArgumentType(Class<?> actual, Class<?> formal)
static boolean
isWindows()
static Class<?>
loadClass(String className, ClassLoader classLoader)
This method will attempt to load the specified Class.static String
relative(File base, File file)
static Class<?>
safeLoadClass(ClassLoader cl, String name)
static String
setter2property(String methodName)
static String
stripExtension(String pResourceName)
Please do not use - internal org/my/Class.xxx -> org/my/Classstatic String
toJavaCasing(String pName)
-
-
-
Method Detail
-
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
-
stripExtension
public static String stripExtension(String pResourceName)
Please do not use - internal org/my/Class.xxx -> org/my/Class
-
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, 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 classargs
- 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 classargs
- 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
-
findClass
public static Class<?> findClass(String name, Collection<String> availableImports, ClassLoader cl)
-
findClass
public static Class<?> findClass(String className, ClassLoader cl)
-
getAccessor
public static Method getAccessor(Class<?> clazz, String field, boolean exceptionIfIncompatible)
-
isTypeCompatibleWithArgumentType
public static boolean isTypeCompatibleWithArgumentType(Class<?> actual, Class<?> formal)
-
isFinal
public static boolean isFinal(Class<?> clazz)
-
isInterface
public static boolean isInterface(Class<?> clazz)
-
isGetter
public static boolean isGetter(String methodName)
-
isSetter
public static boolean isSetter(String methodName)
-
deepClone
public static <T extends Externalizable> T deepClone(T origin)
-
deepClone
public static <T extends Externalizable> T deepClone(T origin, ClassLoader classLoader)
-
deepClone
public static <T extends Externalizable> T deepClone(T origin, ClassLoader classLoader, Map<String,Object> cloningResources)
-
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
-
getClassFromName
public static Class<?> getClassFromName(String className) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
getClassFromName
public static Class<?> getClassFromName(String className, boolean initialize, ClassLoader classLoader) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
safeLoadClass
public static Class<?> safeLoadClass(ClassLoader cl, String name)
-
-