Class UniqueModule

  • All Implemented Interfaces:
    com.google.inject.Module

    public abstract class UniqueModule
    extends com.google.inject.AbstractModule
    Base class for unique modules: only one module instance must be accepted and all others considered duplicate. Note that class only properly implements equals method so guicey deduplication mechanism could filter other instances. It is not required to use this class to grant module uniqueness - you may directly implement equals method in your module.

    Classed are compared by name to properly detect classes from different class loaders.

    Also, note that guice silently ignores duplicate bindings and so in most cases it would be able to handle duplicate modules properly. This class may be used for cases when bindings registered by module instances are not equal (e.g. register something by instance or produce other side effects).

    If module requires access to dropwizard specific project (via DropwizardAwareModule) then use UniqueDropwizardAwareModule instead.

    Since:
    13.07.2019
    See Also:
    GuiceBundle.Builder.duplicateConfigDetector( ru.vyarus.dropwizard.guice.module.context.unique.DuplicateConfigDetector)
    • Constructor Summary

      Constructors 
      Constructor Description
      UniqueModule()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      • Methods inherited from class com.google.inject.AbstractModule

        addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UniqueModule

        public UniqueModule()
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object