Package io.hawt.util
Class ReflectionHelper
- java.lang.Object
-
- io.hawt.util.ReflectionHelper
-
public final class ReflectionHelper extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ReflectionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanhasAnnotation(java.lang.reflect.AnnotatedElement elem, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean checkMetaAnnotations)Checks if a Class or Method are annotated with the given annotationstatic booleanhasMethodWithAnnotation(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean checkMetaAnnotations)Returns true if the given type has a method with the given annotationstatic java.lang.ObjectinvokeMethod(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object... parameters)A helper method to invoke a method via reflection and wrap any exceptions asRuntimeExceptioninstancesstatic <T> TnewInstance(java.lang.Class<T> type)A helper method to create a new instance of a type using the default constructor arguments.
-
-
-
Method Detail
-
newInstance
public static <T> T newInstance(java.lang.Class<T> type)
A helper method to create a new instance of a type using the default constructor arguments.
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object... parameters)A helper method to invoke a method via reflection and wrap any exceptions asRuntimeExceptioninstances- Parameters:
method- the method to invokeinstance- the object instance (or null for static methods)parameters- the parameters to the method- Returns:
- the result of the method invocation
-
hasMethodWithAnnotation
public static boolean hasMethodWithAnnotation(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean checkMetaAnnotations)Returns true if the given type has a method with the given annotation
-
hasAnnotation
public static boolean hasAnnotation(java.lang.reflect.AnnotatedElement elem, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, boolean checkMetaAnnotations)Checks if a Class or Method are annotated with the given annotation- Parameters:
elem- the Class or Method to reflect onannotationType- the annotation typecheckMetaAnnotations- check for meta annotations- Returns:
- true if annotations is present
-
-