Class ReflectionHelper


  • public final class ReflectionHelper
    extends Object
    Helper for working with reflection on classes.

    This code is a copy of org.apache.camel.util.ReflectionHelper to avoid cyclic dependencies between artifacts and camel maven plugins. This code is based on org.apache.camel.spring.util.ReflectionUtils class.

    • Method Detail

      • findMethod

        public static Method findMethod​(Class<?> clazz,
                                        String name,
                                        Class<?>... paramTypes)
        Attempt to find a Method on the supplied class with the supplied name and parameter types. Searches all superclasses up to Object.

        Returns null if no Method can be found.

        Parameters:
        clazz - the class to introspect
        name - the name of the method
        paramTypes - the parameter types of the method (may be null to indicate any signature)
        Returns:
        the Method object, or null if none found
      • findField

        public static Field findField​(Class<?> clazz,
                                      String name)
        Attempt to find a Field on the supplied class with the supplied name. Searches all superclasses up to Object.

        Returns null if no Method can be found.

        Parameters:
        clazz - the class to introspect
        name - the name of the field
        Returns:
        the field object, or null if none found
      • setField

        public static void setField​(Field f,
                                    Object instance,
                                    Object value)