java.lang.Object
ru.vyarus.dropwizard.guice.module.installer.util.FeatureUtils

public final class FeatureUtils extends Object
Utility methods to simplify checks for feature installers.
Since:
01.09.2014
  • Method Details

    • hasAnnotation

      public static boolean hasAnnotation(Class<?> type, Class<? extends Annotation> annotation)
      Parameters:
      type - type to check
      annotation - 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(Class<?> type, Class<? extends Annotation> annotation)
      Parameters:
      type - type to check
      annotation - 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 Annotation> T getAnnotation(Class<?> type, Class<T> annotation)
      Type Parameters:
      T - annotation type
      Parameters:
      type - type to examine
      annotation - 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 examine
      annotation - 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(Class<?> type, Class<?> required)
      Parameters:
      type - type to check
      required - required marker superclass or interface
      Returns:
      if type implements interface or extends required type and type is not abstract
    • getInstallerExtName

      public static String getInstallerExtName(Class<? extends FeatureInstaller> installer)
      Utility call to prettify logs.
      Parameters:
      installer - installer class
      Returns:
      installer name to use in logs
    • findMethod

      @SafeVarargs public static Method findMethod(Class<?> type, String name, Class<Object>... args)
      Parameters:
      type - examining type
      name - method name
      args - method argument types
      Returns:
      found method
    • invokeMethod

      public static <T> T invokeMethod(Method method, Object instance, Object... args)
      Type Parameters:
      T - expected type of execution result
      Parameters:
      method - method to call
      instance - object instance to call method on
      args - optional arguments
      Returns:
      method execution result
    • getInstanceClass

      public static <T> 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