Package org.aksw.commons.util.reflect
Class ClassUtils
java.lang.Object
org.aksw.commons.util.reflect.ClassUtils
- Author:
- Claus Stadler Date: 6/3/11
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaccess(AccessibleObject obj, ThrowingRunnable consumer) static <T> TaccessCalc(AccessibleObject obj, Callable<T> consumer) Stream a classes super class and interfaces as lists of breadthsstatic ObjectforceInvoke(Object o, Method m, Object... args) static ObjectforceInvoke(Method m, Object[] args) getAllNonOverriddenMethods(Class<?> clazz) Returns all non-overridden methods for the given class.getAllNonOverriddenMethods(Class<?> clazz, String name) static Integer[]getDistance(Class<?>[] a, Class<?>[] b) static IntegergetDistance(Class<?> given, Class<?> there) Returns the minimum distance of two classes in an inheritance hierarchy Null if there is no distancestatic Integer[]getDistance(Class<?> ra, Class<?> rb, Class<?>[] a, Class<?>[] b) Including return typesstatic <T> TgetFieldValue(Class<?> clazz, String fieldName, Object obj) static <T> TgetFieldValue(Object obj, String fieldName) static <T> TgetFieldValueChecked(Class<?> clazz, String fieldName, Object obj) static FieldgetMostSpecificSubclasses(Class<?> given, Collection<Class<?>> classes) getNonSubsumedClasses(Collection<Class<?>> classes) static IntegergetRelation(Integer[] a, Integer[] b) static Class<?>[]getTypeSignature(Object[] args) getTypeSignatureList(Object[] args) static voidsetFieldValue(Class<?> clazz, String fieldName, Object obj, Object value) static voidsetFieldValue(Object obj, String fieldName, Object value) static voidsetFieldValueChecked(Class<?> clazz, String fieldName, Object obj, Object value) static <T> Supplier<T>supplierFromCtor(Class<?> cls, boolean createTestInstance) Return a supplier that invokes the given class' no-arg constructor.static <T> Supplier<T>supplierFromCtor(Constructor<?> ctor, boolean createTestInstance) Return a supplier that invokes the constructor.
-
Constructor Details
-
ClassUtils
public ClassUtils()
-
-
Method Details
-
getDirectSuperclassAndInterfaces
-
bfsStream
Stream a classes super class and interfaces as lists of breadths -
getFieldValueChecked
public static <T> T getFieldValueChecked(Class<?> clazz, String fieldName, Object obj) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException -
getFieldValue
-
getFieldValue
-
getModifiersField
-
setFieldValueChecked
public static void setFieldValueChecked(Class<?> clazz, String fieldName, Object obj, Object value) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException -
access
-
accessCalc
-
setFieldValue
-
setFieldValue
-
forceInvoke
-
forceInvoke
-
getDistance
Returns the minimum distance of two classes in an inheritance hierarchy Null if there is no distance -
getTypeSignatureList
-
getTypeSignature
-
getDistance
-
getDistance
Including return types- Parameters:
ra-rb-a-b-- Returns:
-
getRelation
- Parameters:
a-b-- Returns:
- L, LE, E, GE, G, Mixed
-
getAllNonOverriddenMethods
Returns all non-overridden methods for the given class.- Parameters:
clazz-- Returns:
-
getAllNonOverriddenMethods
- Parameters:
clazz-name- Convenience filter by name- Returns:
-
getMostSpecificSubclasses
-
getNonSubsumedClasses
-
supplierFromCtor
Return a supplier that invokes the given class' no-arg constructor.- Parameters:
cls- The classcreateTestInstance- If true then for verification an instance is taken from the created supplier immediately.
-
supplierFromCtor
Return a supplier that invokes the constructor.- Parameters:
ctor- The constructorcreateTestInstance- If true then for verification an instance is taken from the created supplier immediately.
-