Package pcap.common.util
Class Reflections
java.lang.Object
pcap.common.util.Reflections
@Inclubating public class Reflections extends Object
- Author:
- Ardika Rommy Sanjaya
-
Constructor Summary
Constructors Constructor Description Reflections()
-
Method Summary
Modifier and Type Method Description static Throwable
forceSetAccessible(AccessibleObject object, boolean checkAccessible)
static List<Class<?>>
getAllClasses(Class<?> cls)
Gets aList
of superclasses and class it self for the given class.static List<Class<?>>
getAllClassesAndInterfaces(Class<?> cls)
Get aList
of all classes and interfaces.static List<Class<?>>
getAllInterfaces(Class<?> cls)
Gets aList
of all interfaces implemented by the given class and its superclasses.static List<Class<?>>
getAllSuperClasses(Class<?> cls)
Gets aList
of superclasses for the given class.static List<Class<?>>
getAllSuperClassesAndInterfaces(Class<?> cls)
Get aList
of all super classes and interfaces.static Field
getPublicFiled(Class<?> cls, String fieldName)
Get public field from current or super class/interface.static Method
getPublicMethod(Class<?> cls, String methodName, Class<?>... parameterTypes)
Get public method from current or super class/interface.static boolean
isInnerClass(Class<?> cls)
Is the specified class an inner class or static nested class.static Throwable
trySetAccessible(AccessibleObject object, boolean checkAccessible)
-
Constructor Details
-
Reflections
public Reflections()
-
-
Method Details
-
trySetAccessible
public static Throwable trySetAccessible(AccessibleObject object, boolean checkAccessible) throws RuntimeException- Throws:
RuntimeException
-
forceSetAccessible
public static Throwable forceSetAccessible(AccessibleObject object, boolean checkAccessible) throws RuntimeException- Throws:
RuntimeException
-
getAllSuperClasses
Gets aList
of superclasses for the given class.- Parameters:
cls
- the class to look up.- Returns:
- returns
List
of superclasses.
-
getAllClasses
Gets aList
of superclasses and class it self for the given class.- Parameters:
cls
- the class to look up.- Returns:
- returns
List
of superclasses and class it self.
-
getAllInterfaces
Gets aList
of all interfaces implemented by the given class and its superclasses.- Parameters:
cls
- the class to look up.- Returns:
- returns
List
of interfaces.
-
getAllClassesAndInterfaces
Get aList
of all classes and interfaces.- Parameters:
cls
- the class to look up.- Returns:
- returns
List
of all classes and interfaces.
-
getAllSuperClassesAndInterfaces
Get aList
of all super classes and interfaces.- Parameters:
cls
- the class to look up.- Returns:
- returns
List
of all super classes and interfaces.
-
getPublicFiled
Get public field from current or super class/interface.- Parameters:
cls
- the class to look up.fieldName
- field name.- Returns:
- returns
Field
. - Throws:
NoSuchFieldException
- field not found.
-
getPublicMethod
public static Method getPublicMethod(Class<?> cls, String methodName, Class<?>... parameterTypes) throws NoSuchMethodExceptionGet public method from current or super class/interface.- Parameters:
cls
- the class to look up.methodName
- method name.parameterTypes
- parameter types.- Returns:
- returns
Method
. - Throws:
NoSuchMethodException
- method not found.
-
isInnerClass
Is the specified class an inner class or static nested class.- Parameters:
cls
- the class to check, may be null.- Returns:
true
if the class is an inner or static nested class, false if not ornull
-