Package org.apache.nifi.util
Class ReflectionUtils
java.lang.Object
org.apache.nifi.util.ReflectionUtils
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
invokeMethodsWithAnnotation
(Class<? extends Annotation> annotation, Object instance, Object... args) Invokes all methods on the given instance that have been annotated with the given Annotation.static boolean
quietlyInvokeMethodsWithAnnotation
(Class<? extends Annotation> annotation, Object instance, Object... args) Invokes all methods on the given instance that have been annotated with the given Annotation.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
invokeMethodsWithAnnotation
public static void invokeMethodsWithAnnotation(Class<? extends Annotation> annotation, Object instance, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException Invokes all methods on the given instance that have been annotated with the given Annotation. If the signature of the method that is defined ininstance
uses 1 or more parameters, those parameters must be specified by theargs
parameter. However, if more arguments are supplied by theargs
parameter than needed, the extra arguments will be ignored.- Parameters:
annotation
- the annotation to look forinstance
- to invoke a method ofargs
- to supply in a method call- Throws:
InvocationTargetException
- iteIllegalArgumentException
- iaeIllegalAccessException
- if not allowed to invoke that method
-
quietlyInvokeMethodsWithAnnotation
public static boolean quietlyInvokeMethodsWithAnnotation(Class<? extends Annotation> annotation, Object instance, Object... args) Invokes all methods on the given instance that have been annotated with the given Annotation. If the signature of the method that is defined ininstance
uses 1 or more parameters, those parameters must be specified by theargs
parameter. However, if more arguments are supplied by theargs
parameter than needed, the extra arguments will be ignored.- Parameters:
annotation
- the annotation to look forinstance
- to invoke a method ofargs
- to supply in a method call- Returns:
true
if all appropriate methods were invoked and returned without throwing an Exception,false
if one of the methods threw an Exception or could not be invoked; iffalse
is returned, an error will have been logged.
-