Class InjectionLayerRegistry

java.lang.Object
eu.cloudnetservice.driver.inject.InjectionLayerRegistry

@Internal final class InjectionLayerRegistry extends Object
A registry for injection layers which can be bound to specific hints.
Since:
4.0
  • Field Details

  • Constructor Details

    • InjectionLayerRegistry

      InjectionLayerRegistry()
  • Method Details

    • registerLayer

      public void registerLayer(@NonNull @NonNull InjectionLayer<? extends Injector> layer, @NonNull @NonNull Object... hints)
      Registers to this registry and maps the given hints to the layer. During the process, there will be no calls to either equals or hashCode. For later lookups, the given hint must be exactly as one of the given hints (as defined by the operator ==).

      Note that layer registrations are ordered. If different layers are registered for the same hint instance, the first one that was registered first will be returned.

      Parameters:
      layer - the layer to register to this registry.
      hints - the hints to associate the given layer with.
      Throws:
      NullPointerException - if either the given layer or hints are null.
    • unregisterLayer

      public void unregisterLayer(@NonNull @NonNull InjectionLayer<?> layer)
      Unregisters all hints that were associated with the given layer. The layer to unregister is defined by the same instance given to the method (as defined by the operator ==).
      Parameters:
      layer - the layer to unregister the hints of.
      Throws:
      NullPointerException - if the gien layer is null.
    • findByHint

      @Nullable public @Nullable InjectionLayer<? extends Injector> findByHint(@Nullable @Nullable Object hint)
      Finds the first layer which is exactly associated with the given hint (as defined by the operator ==).
      Parameters:
      hint - the hint to find the layer of.
      Returns:
      the injection layer associated with the hint, or null if no layer is associated.
      Throws:
      NullPointerException - if the given hint is null.