Class BindingUtils


  • public final class BindingUtils
    extends java.lang.Object
    Guice bindings utils.
    Since:
    29.08.2019
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String JIT_MODULE
      Used to mark undeclared elemnts (not declared manually in any module).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getDeclarationSource​(com.google.inject.Binding binding)
      Resolve binding declaration source string, if possible.
      static java.lang.Class<? extends com.google.inject.Module> getModuleClass​(java.lang.String name)
      Resolve class from module name, resolved from guice Element source.
      static java.util.List<java.lang.String> getModules​(com.google.inject.spi.Element element)
      Resolve guice configuration element declaration module chain.
      static java.lang.Class<? extends com.google.inject.Module> getTopDeclarationModule​(com.google.inject.spi.Element element)
      May return Module if JIT binding provided.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JIT_MODULE

        public static final java.lang.String JIT_MODULE
        Used to mark undeclared elemnts (not declared manually in any module).
        See Also:
        Constant Field Values
    • Method Detail

      • getModules

        public static java.util.List<java.lang.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 java.lang.Class<? extends com.google.inject.Module> getModuleClass​(java.lang.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 java.lang.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 java.lang.String getDeclarationSource​(com.google.inject.Binding binding)
        Resolve binding declaration source string, if possible.
        Parameters:
        binding - binding
        Returns:
        binding declaration source