Class FeatureUtils
java.lang.Object
ru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils
Utility methods to simplify checks for feature installers.
- Since:
- 01.09.2014
-
Method Summary
Modifier and TypeMethodDescriptionstatic MethodfindMethod(Class<?> type, String name, Class<Object>... args) static <T extends Annotation>
AnnotationgetAnnotatedAnnotation(Class<?> type, Class<T> annotation) static <T extends Annotation>
TgetAnnotation(Class<?> type, Class<T> annotation) static StringgetInstallerExtName(Class<? extends FeatureInstaller> installer) Utility call to prettify logs.static <T> Class<T>getInstanceClass(T object) Used to get correct object type even if it's guice proxy.static booleanhasAnnotatedAnnotation(Class<?> type, Class<? extends Annotation> annotation) static booleanhasAnnotation(Class<?> type, Class<? extends Annotation> annotation) static <T> TinvokeMethod(Method method, Object instance, Object... args) static boolean
-
Method Details
-
hasAnnotation
- Parameters:
type- type to checkannotation- annotation to find- Returns:
- true if annotation found on class or super class and type is not abstract, false otherwise
-
hasAnnotatedAnnotation
- Parameters:
type- type to checkannotation- annotation to find- Returns:
- true if annotation found on one of class or super class annotations and type is not abstract, false otherwise
-
getAnnotation
- Type Parameters:
T- annotation type- Parameters:
type- type to examineannotation- annotation to search- Returns:
- found annotation or null
-
getAnnotatedAnnotation
public static <T extends Annotation> Annotation getAnnotatedAnnotation(Class<?> type, Class<T> annotation) - Type Parameters:
T- annotation type- Parameters:
type- type to examineannotation- annotation which must be found on target annotation- Returns:
- annotation annotated with provided annotation type or null if not found
-
is
- Parameters:
type- type to checkrequired- required marker superclass or interface- Returns:
- if type implements interface or extends required type and type is not abstract
-
getInstallerExtName
Utility call to prettify logs.- Parameters:
installer- installer class- Returns:
- installer name to use in logs
-
findMethod
- Parameters:
type- examining typename- method nameargs- method argument types- Returns:
- found method
-
invokeMethod
- Type Parameters:
T- expected type of execution result- Parameters:
method- method to callinstance- object instance to call method onargs- optional arguments- Returns:
- method execution result
-
getInstanceClass
Used to get correct object type even if it's guice proxy.- Type Parameters:
T- object type- Parameters:
object- object to get class of- Returns:
- object class
-