Class Classes
- java.lang.Object
-
- dk.cloudcreate.essentials.shared.reflection.Classes
-
-
Constructor Summary
Constructors Constructor Description Classes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcompareTypeSpecificity(Class<?> leftSide, Class<?> rightSide)ComparesleftSidewith therightSidefor inheritance order.
It returns: negative integer - if the leftSide is less specific then the rightSide
Example: If leftSide is a CharSequence and rightSide is a String (a specialization of CharSequence). zero - if the leftSide is equally specific to rightSide (i.e.static Class<?>forName(String fullyQualifiedClassName)Load a class based on a fully qualified class namestatic Class<?>forName(String fullyQualifiedClassName, ClassLoader classLoader)Load a class based on a fully qualified class name and using a specificClassLoaderstatic List<Class<?>>superClasses(Class<?> type)Get all superclasses of a type.
-
-
-
Method Detail
-
forName
public static Class<?> forName(String fullyQualifiedClassName) throws ReflectionException
Load a class based on a fully qualified class name- Parameters:
fullyQualifiedClassName- the Fully Qualified Class Name as a- Returns:
- The class loaded
- Throws:
ReflectionException- in case loading the class failed
-
forName
public static Class<?> forName(String fullyQualifiedClassName, ClassLoader classLoader) throws ReflectionException
Load a class based on a fully qualified class name and using a specificClassLoader- Parameters:
fullyQualifiedClassName- the Fully Qualified Class Name as a stringclassLoader- the class loader to use- Returns:
- The class loaded
- Throws:
ReflectionException- in case loading the class failed
-
compareTypeSpecificity
public static int compareTypeSpecificity(Class<?> leftSide, Class<?> rightSide)
ComparesleftSidewith therightSidefor inheritance order.
It returns:- negative integer - if the leftSide is less specific then the rightSide
Example: If leftSide is a CharSequence and rightSide is a String (a specialization of CharSequence). - zero - if the leftSide is equally specific to rightSide (i.e. leftSide and rightSide are the same class)
Example: If leftSide is a CharSequence and rightSide is a CharSequence - negative integer - if the leftSide is more specific then the rightSide
Example: If leftSide is a String (a subclass of CharSequence) and rightSide is a CharSequence.
- Parameters:
leftSide- the left side typerightSide- the right side type- Returns:
- the inheritance comparison between the leftSide and rightSide
- Throws:
IllegalArgumentException- in case leftSide and rightSide aren't either the same class or in a inheritance hierarchy with each other
- negative integer - if the leftSide is less specific then the rightSide
-
-