Package eu.cloudnetservice.driver.inject
Record Class DefaultInjectionLayer<I extends dev.derklaro.aerogel.Injector>
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.inject.DefaultInjectionLayer<I>
- Type Parameters:
I- the type of injector this layer uses.- Record Components:
injector- the injector to use for the layer.autoRegistry- the auto registry to use for the layer.name- the name of this injection layer.
- All Implemented Interfaces:
eu.cloudnetservice.common.Nameable,InjectionLayer<I>,AutoCloseable
record DefaultInjectionLayer<I extends dev.derklaro.aerogel.Injector>(I extends dev.derklaro.aerogel.Injector injector, @NonNull dev.derklaro.aerogel.auto.runtime.AutoAnnotationRegistry autoRegistry, @NonNull String name)
extends Record
implements InjectionLayer<I>
The default implementation for of an injector layer.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull dev.derklaro.aerogel.auto.runtime.AutoAnnotationRegistryThe field for theautoRegistryrecord component.private final IThe field for theinjectorrecord component.The field for thenamerecord component.Fields inherited from interface eu.cloudnetservice.driver.inject.InjectionLayer
AUTO_CONFIGURE_FILE_NAME_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionDefaultInjectionLayer(I injector, @NonNull dev.derklaro.aerogel.auto.runtime.AutoAnnotationRegistry autoRegistry, @NonNull String name) Creates an instance of aDefaultInjectionLayerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionMakes this injection layer not closeable, returning the same layer if it is already not closeable.@NonNull dev.derklaro.aerogel.auto.runtime.AutoAnnotationRegistryReturns the value of theautoRegistryrecord component.voidclose()Closes this injector and removes all leftover bindings (if any).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.injector()Gets the underlying injector of this layer.voidInstalls the binding constructed by the given bindings constructor to this injection layer.voidinstallAutoConfigureBindings(@NonNull ClassLoader loader, @NonNull String component) Installs the autoconfiguration bindings for the given component.<T> @UnknownNullability TConvince method to create or get the instance of the given element.<T> @UnknownNullability TConvince method to create or get the instance of the given class type.<T> @UnknownNullability Tinstance(@NonNull Class<T> type, @NonNull Consumer<dev.derklaro.aerogel.InjectionContext.Builder> builder) Convince method to create or get the instance of the given type, while allowing to specifically influence the injection context.name()Returns the value of thenamerecord component.Registers this injection layer to the injection layer registry.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
injector
The field for theinjectorrecord component. -
autoRegistry
@NonNull private final @NonNull dev.derklaro.aerogel.auto.runtime.AutoAnnotationRegistry autoRegistryThe field for theautoRegistryrecord component. -
name
The field for thenamerecord component.
-
-
Constructor Details
-
DefaultInjectionLayer
DefaultInjectionLayer(@NonNull I injector, @NonNull @NonNull dev.derklaro.aerogel.auto.runtime.AutoAnnotationRegistry autoRegistry, @NonNull @NonNull String name) Creates an instance of aDefaultInjectionLayerrecord class.- Parameters:
injector- the value for theinjectorrecord componentautoRegistry- the value for theautoRegistryrecord componentname- the value for thenamerecord component
-
-
Method Details
-
injector
Gets the underlying injector of this layer.- Specified by:
injectorin interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Returns:
- the underlying injector of this layer.
-
instance
Convince method to create or get the instance of the given class type.- Specified by:
instancein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Type Parameters:
T- the type of the class modeled by the given class object.- Parameters:
type- the type of the element to get.- Returns:
- the constructed instance of the class type, may be null.
-
instance
Convince method to create or get the instance of the given element.- Specified by:
instancein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Type Parameters:
T- the type of the return value modeled by the given element.- Parameters:
element- the element of the type to get.- Returns:
- the constructed instance of the class type, may be null.
-
instance
public <T> @UnknownNullability T instance(@NonNull @NonNull Class<T> type, @NonNull @NonNull Consumer<dev.derklaro.aerogel.InjectionContext.Builder> builder) Convince method to create or get the instance of the given type, while allowing to specifically influence the injection context.- Specified by:
instancein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Type Parameters:
T- the type of the return value modeled by the given element.- Parameters:
type- the type of the element to get.builder- the builder to configure the injection context for the operation.- Returns:
- the constructed instance of the class type, may be null.
-
install
Installs the binding constructed by the given bindings constructor to this injection layer.- Specified by:
installin interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Parameters:
constructor- the constructor to install.
-
installAutoConfigureBindings
public void installAutoConfigureBindings(@NonNull @NonNull ClassLoader loader, @NonNull @NonNull String component) Installs the autoconfiguration bindings for the given component. For this method to work the autoconfiguration bindings must be located atautoconfigure/<component>.aero.This method binds the autoconfiguration bindings to the underlying injector of this layer.
- Specified by:
installAutoConfigureBindingsin interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Parameters:
loader- the loader in which the file resource is located.component- the name of the component to load the autoconfiguration bindings of.
-
asUncloseable
Makes this injection layer not closeable, returning the same layer if it is already not closeable.- Specified by:
asUncloseablein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Returns:
- the same injection layer from the functionality, but not closeable.
-
register
Registers this injection layer to the injection layer registry. Subsequent calls toInjectionLayer.findLayerOf(Object)will be able to resolve the layer if the given object value is the exact the same as given as one of the hints (exact as by using the==compare operation).Note that the layer lookup order is predictable based on the call order of register. If different layers are registered for the same objects, the first layer to be registered will be found.
- Specified by:
registerin interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Parameters:
hints- the hints to use for the layer registration.- Returns:
- the same layer as used to call the method, for chaining.
-
close
public void close()Closes this injector and removes all leftover bindings (if any).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
autoRegistry
Returns the value of theautoRegistryrecord component.- Returns:
- the value of the
autoRegistryrecord component
-
name
Returns the value of thenamerecord component.- Specified by:
namein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Specified by:
namein interfaceeu.cloudnetservice.common.Nameable- Returns:
- the value of the
namerecord component
-