Class ReflectionUtils


  • @Component("reflectionUtils")
    public class ReflectionUtils
    extends java.lang.Object
    Provides some helper methods for Java's Reflection API.
    Since:
    2.0.0
    Author:
    Oliver Libutzki <[email protected]>
    • Constructor Summary

      Constructors 
      Constructor Description
      ReflectionUtils()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Class<?> getDeclaringClass​(java.lang.reflect.AnnotatedElement annotatedElement)
      Returns the Class which contains the given AnnotatedElement.
      java.lang.reflect.Method getDeclaringMethod​(java.lang.reflect.AnnotatedElement annotatedElement)
      Returns the Method which contains the given AnnotatedElement.
      boolean hasSignature​(java.lang.reflect.Method method, java.lang.String expectedName, java.lang.Class<?>... expectedParameterTypes)
      Returns true if the given method has the expected name and parameter types.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReflectionUtils

        public ReflectionUtils()
    • Method Detail

      • getDeclaringClass

        public java.lang.Class<?> getDeclaringClass​(java.lang.reflect.AnnotatedElement annotatedElement)
        Returns the Class which contains the given AnnotatedElement. If the given AnnotatedElement is a Class, it is returned.
        Parameters:
        annotatedElement - the annotated element which's containing Class should be determined
        Returns:
        the containing class
        Since:
        2.0.0
      • getDeclaringMethod

        public java.lang.reflect.Method getDeclaringMethod​(java.lang.reflect.AnnotatedElement annotatedElement)
        Returns the Method which contains the given AnnotatedElement. If the given AnnotatedElement is a Method, it is returned.
        Parameters:
        annotatedElement - the annotated element which's containing Method should be determined
        Returns:
        the containing method
        Since:
        2.0.0
      • hasSignature

        public boolean hasSignature​(java.lang.reflect.Method method,
                                    java.lang.String expectedName,
                                    java.lang.Class<?>... expectedParameterTypes)
        Returns true if the given method has the expected name and parameter types.
        Parameters:
        method - the method to check
        expectedName - the expected method name
        expectedParameterTypes - the expected parameter types
        Returns:
        true if the given method has the expected name and parameter types, otherwise false