public final class ReflectionHelper extends Object
Constructor and Description |
---|
ReflectionHelper() |
Modifier and Type | Method and Description |
---|---|
static boolean |
hasAnnotation(AnnotatedElement elem,
Class<? extends Annotation> annotationType,
boolean checkMetaAnnotations)
Checks if a Class or Method are annotated with the given annotation
|
static boolean |
hasMethodWithAnnotation(Class<?> type,
Class<? extends Annotation> annotationType,
boolean checkMetaAnnotations)
Returns true if the given type has a method with the given annotation
|
static Object |
invokeMethod(Method method,
Object instance,
Object... parameters)
A helper method to invoke a method via reflection and wrap any exceptions
as
RuntimeException instances |
static <T> T |
newInstance(Class<T> type)
A helper method to create a new instance of a type using the default
constructor arguments.
|
public static <T> T newInstance(Class<T> type)
public static Object invokeMethod(Method method, Object instance, Object... parameters)
RuntimeException
instancesmethod
- the method to invokeinstance
- the object instance (or null for static methods)parameters
- the parameters to the methodpublic static boolean hasMethodWithAnnotation(Class<?> type, Class<? extends Annotation> annotationType, boolean checkMetaAnnotations)
public static boolean hasAnnotation(AnnotatedElement elem, Class<? extends Annotation> annotationType, boolean checkMetaAnnotations)
elem
- the Class or Method to reflect onannotationType
- the annotation typecheckMetaAnnotations
- check for meta annotationsCopyright © 2021 JBoss by Red Hat. All rights reserved.