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

public final class BindingUtils extends Object
Guice bindings utils.
Since:
29.08.2019
  • Field Details

    • JIT_MODULE

      public static final String JIT_MODULE
      Used to mark undeclared elemnts (not declared manually in any module).
      See Also:
  • Method Details

    • getModules

      public static List<String> getModules(com.google.inject.spi.Element element)
      Resolve guice configuration element declaration module chain. The first list element is declaration module. Later elements appear if module was installed by other module.

      Modules declared with lambda expression removed. If there are upper modules, declared normally then only they would remain (in report bindings would be should directly as module's bindings). When no upper modules exists then returned chain would contain only Module to group all bindings from all root lambda modules into single "meta" module in the report (code links would still be correct in the report).

      Parameters:
      element - guice SPI element
      Returns:
      modules chain from declaration point or single JIT_MODULE if binding is a JIT binding
    • getModuleClass

      public static Class<? extends com.google.inject.Module> getModuleClass(String name)
      Resolve class from module name, resolved from guice Element source. May return Module if element was a jit binding and provided name is JIT_MODULE.
      Parameters:
      name - module full class name (or jit marker)
      Returns:
      module class or Module for jit marker
    • getTopDeclarationModule

      public static Class<? extends com.google.inject.Module> getTopDeclarationModule(com.google.inject.spi.Element element)
      May return Module if JIT binding provided.
      Parameters:
      element - guice SPI element
      Returns:
      top module class name
    • getDeclarationSource

      public static String getDeclarationSource(com.google.inject.Binding binding)
      Resolve binding declaration source string, if possible.
      Parameters:
      binding - binding
      Returns:
      binding declaration source
    • findScopingAnnotation

      public static Class<? extends Annotation> findScopingAnnotation(Class<?> type, boolean countGuiceSpecific)
      Searches for scoping annotation on class. Base classes are not checked as scope is not inheritable.
      Parameters:
      type - class to search for
      countGuiceSpecific - true to count guice-specific annotations (with ScopeAnnotation)
      Returns:
      detected annotation or null