Class ReflectionUtils
java.lang.Object
fr.paris.lutece.portal.util.mvc.utils.ReflectionUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAction to take on each method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddoWithLocalMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc) Perform the given callback operation on all matching methods of the given class, as locally declared or equivalent thereof (such as default methods on Java 8 based interfaces that the given class implements).static voiddoWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc) Perform the given callback operation on all matching methods of the given class and superclasses.static Method[]getAllDeclaredMethods(Class<?> leafClass) Get all declared methods on the leaf class and all superclasses.static Method[]getDeclaredMethods(Class<?> clazz) Variant ofClass.getDeclaredMethods()that uses a local cache in order to avoid new Method instances.
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
getAllDeclaredMethods
Get all declared methods on the leaf class and all superclasses. Leaf class methods are included first.- Parameters:
leafClass- the class to introspect- Throws:
IllegalStateException- if introspection fails
-
doWithLocalMethods
Perform the given callback operation on all matching methods of the given class, as locally declared or equivalent thereof (such as default methods on Java 8 based interfaces that the given class implements).- Parameters:
clazz- the class to introspectmc- the callback to invoke for each method- Throws:
IllegalStateException- if introspection fails- See Also:
-
getDeclaredMethods
Variant ofClass.getDeclaredMethods()that uses a local cache in order to avoid new Method instances. In addition, it also includes Java 8 default methods from locally implemented interfaces, since those are effectively to be treated just like declared methods.- Parameters:
clazz- the class to introspect- Returns:
- the cached array of methods
- Throws:
IllegalStateException- if introspection fails- See Also:
-
doWithMethods
Perform the given callback operation on all matching methods of the given class and superclasses.The same named method occurring on subclass and superclass will appear twice, unless excluded by a
MethodFilter.- Parameters:
clazz- the class to introspectmc- the callback to invoke for each method- Throws:
IllegalStateException- if introspection fails- See Also:
-
#doWithMethods(Class, MethodCallback, MethodFilter)
-