Class ReflectionUtils

java.lang.Object
fr.paris.lutece.portal.util.mvc.utils.ReflectionUtils

public class ReflectionUtils extends Object
  • Constructor Details

    • ReflectionUtils

      public ReflectionUtils()
  • Method Details

    • getAllDeclaredMethods

      public static Method[] getAllDeclaredMethods(Class<?> leafClass)
      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

      public static void doWithLocalMethods(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).
      Parameters:
      clazz - the class to introspect
      mc - the callback to invoke for each method
      Throws:
      IllegalStateException - if introspection fails
      See Also:
    • getDeclaredMethods

      public static Method[] getDeclaredMethods(Class<?> clazz)
      Variant of Class.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

      public static void doWithMethods(Class<?> clazz, ReflectionUtils.MethodCallback mc)
      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 introspect
      mc - the callback to invoke for each method
      Throws:
      IllegalStateException - if introspection fails
      See Also:
      • #doWithMethods(Class, MethodCallback, MethodFilter)