Package de.bmiag.tapir.util.reflect
Class ReflectionUtils
- java.lang.Object
-
- de.bmiag.tapir.util.reflect.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 theClass
which contains the givenAnnotatedElement
.java.lang.reflect.Method
getDeclaringMethod(java.lang.reflect.AnnotatedElement annotatedElement)
Returns theMethod
which contains the givenAnnotatedElement
.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.
-
-
-
Method Detail
-
getDeclaringClass
public java.lang.Class<?> getDeclaringClass(java.lang.reflect.AnnotatedElement annotatedElement)
Returns theClass
which contains the givenAnnotatedElement
. If the givenAnnotatedElement
is aClass
, it is returned.- Parameters:
annotatedElement
- the annotated element which's containingClass
should be determined- Returns:
- the containing class
- Since:
- 2.0.0
-
getDeclaringMethod
public java.lang.reflect.Method getDeclaringMethod(java.lang.reflect.AnnotatedElement annotatedElement)
Returns theMethod
which contains the givenAnnotatedElement
. If the givenAnnotatedElement
is aMethod
, it is returned.- Parameters:
annotatedElement
- the annotated element which's containingMethod
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 checkexpectedName
- the expected method nameexpectedParameterTypes
- the expected parameter types- Returns:
- true if the given method has the expected name and parameter types, otherwise false
-
-