Class BindingGenerators

java.lang.Object
io.activej.inject.binding.BindingGenerators

public final class BindingGenerators extends Object
  • Constructor Details

    • BindingGenerators

      public BindingGenerators()
  • Method Details

    • refusing

      public static <T> BindingGenerator<T> refusing()
      Default generator that never generates anything.
    • combinedGenerator

      public static BindingGenerator<?> combinedGenerator(Map<KeyPattern<?>,Set<BindingGenerator<?>>> generators)
      Modules export a multimap of binding generators with raw class keys.

      This generator aggregates such map into one big generator to be used by Injector.compile(io.activej.inject.Injector, io.activej.inject.module.Module) method. For each requested key, a set of generators is fetched based on its raw class. All generators from this set are then called and if one and only one of them generated a binding then this binding is returned. When nobody generated a binding then combined generator didn't as well, and it is considered an error when more than one did.

      When raw class of the requested key is an interface, it is matched by equality, and when it is some class then generator of its closest superclass will be called.

      Be aware of that when creating generators for some concrete classes: usually they are made for interfaces or for final classes.