Class FeatureUtils
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils
-
public final class FeatureUtils extends java.lang.Object
Utility methods to simplify checks for feature installers.- Since:
- 01.09.2014
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.reflect.Method
findMethod(java.lang.Class<?> type, java.lang.String name, java.lang.Class<java.lang.Object>... args)
static <T extends java.lang.annotation.Annotation>
java.lang.annotation.AnnotationgetAnnotatedAnnotation(java.lang.Class<?> type, java.lang.Class<T> annotation)
static <T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.Class<?> type, java.lang.Class<T> annotation)
static java.lang.String
getInstallerExtName(java.lang.Class<? extends FeatureInstaller> installer)
Utility call to prettify logs.static <T> java.lang.Class<T>
getInstanceClass(T object)
Used to get correct object type even if it's guice proxy.static boolean
hasAnnotatedAnnotation(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
static boolean
hasAnnotation(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
static <T> T
invokeMethod(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object... args)
static boolean
is(java.lang.Class<?> type, java.lang.Class<?> required)
-
-
-
Method Detail
-
hasAnnotation
public static boolean hasAnnotation(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- 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
public static boolean hasAnnotatedAnnotation(java.lang.Class<?> type, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
- 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
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<?> type, java.lang.Class<T> annotation)
- Type Parameters:
T
- annotation type- Parameters:
type
- type to examineannotation
- annotation to search- Returns:
- found annotation or null
-
getAnnotatedAnnotation
public static <T extends java.lang.annotation.Annotation> java.lang.annotation.Annotation getAnnotatedAnnotation(java.lang.Class<?> type, java.lang.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
public static boolean is(java.lang.Class<?> type, java.lang.Class<?> required)
- 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
public static java.lang.String getInstallerExtName(java.lang.Class<? extends FeatureInstaller> installer)
Utility call to prettify logs.- Parameters:
installer
- installer class- Returns:
- installer name to use in logs
-
findMethod
@SafeVarargs public static java.lang.reflect.Method findMethod(java.lang.Class<?> type, java.lang.String name, java.lang.Class<java.lang.Object>... args)
- Parameters:
type
- examining typename
- method nameargs
- method argument types- Returns:
- found method
-
invokeMethod
public static <T> T invokeMethod(java.lang.reflect.Method method, java.lang.Object instance, java.lang.Object... args)
- 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
public static <T> java.lang.Class<T> getInstanceClass(T object)
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
-
-