Class InjectionLayerRegistry
java.lang.Object
eu.cloudnetservice.driver.inject.InjectionLayerRegistry
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Collection<Tuple2<Object, InjectionLayer<? extends Injector>>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@Nullable InjectionLayer<? extends Injector> findByHint(@Nullable Object hint) Finds the first layer which is exactly associated with the given hint (as defined by the operator==).voidregisterLayer(@NonNull InjectionLayer<? extends Injector> layer, @NonNull Object... hints) Registers to this registry and maps the given hints to the layer.voidunregisterLayer(@NonNull InjectionLayer<?> layer) Unregisters all hints that were associated with the given layer.
-
Field Details
-
knownLayers
-
-
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
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.
-