Package overit.geocall.util
Class Reflector
java.lang.Object
overit.geocall.util.Reflector
Utility class that have utility routine to facilitate the java reflection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?> findSuperGenericClass(Class<?> c, int n, Class<?> def) query for the nth generic type of the parent of a class.static FieldgetAccessibleField(String name, Class cc, Class superexcluded) Returns the accessible fieldgetAccessibleFields(Class cc, Class superexcluded) Returns the accessible fieldstatic Method[]getAllMethods(Class c, String name, boolean sub, Class... params) Returns all the methods of a classstatic intgetStaticInt(Class c, String name, int def) Returns the static intstatic LonggetStaticLong(Class c, String name, Long def) Returns the static longstatic Class<?> getSuperGenericClass(Class<?> c, int n, Class<?> def) query for the nth generic type of the parent of a class.static booleanmatchMethod(Method m, String name, boolean sub, Class... params) Returns if the method match
-
Constructor Details
-
Reflector
public Reflector()
-
-
Method Details
-
getStaticInt
Returns the static int- Parameters:
c- TheClassto get the intname- The name of the fielddef- The default value- Returns:
- The static int of the class with the corrisponding name, if not found returns def
-
getStaticLong
Returns the static long- Parameters:
c- TheClassto get the longname- The name of the fielddef- The default value- Returns:
- The static long of the class with the corrisponding name, if not found returns def
-
getAccessibleField
public static Field getAccessibleField(String name, Class cc, Class superexcluded) throws NoSuchFieldException Returns the accessible field- Parameters:
name- The name of the declared fieldcc- TheClassto get the fieldsuperexcluded- TheClassto exclude- Returns:
- The accessible
Field - Throws:
NoSuchFieldException- if there is no such filed
-
getAccessibleFields
Returns the accessible field -
getAllMethods
Returns all the methods of a class -
matchMethod
Returns if the method match -
getSuperGenericClass
query for the nth generic type of the parent of a class. This method perform a lookup only to the direct super class (if any)- Parameters:
c- the class to be queriedn- the nth generic to be looked fordef- the default class returned when the nth generic type is not a class (for example it is a variable) or if the parent has no generics- Returns:
- the Class type of the generic
-
findSuperGenericClass
query for the nth generic type of the parent of a class. This method perform a lookup over the super classes hierarchy- Parameters:
c- the class to be queriedn- the nth generic to be looked fordef- the default class returned when the nth generic type is not a class (for example it is a variable) or if the parent has no generics- Returns:
- the Class type of the generic
-