Record Class UncloseableInjectionLayer<I extends dev.derklaro.aerogel.Injector>
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.inject.UncloseableInjectionLayer<I>
- Type Parameters:
I- the type of injector used by the parent layer.- Record Components:
parent- the parent layer to delegate all calls to.
- All Implemented Interfaces:
Named,InjectionLayer<I>,AutoCloseable
@Internal
record UncloseableInjectionLayer<I extends dev.derklaro.aerogel.Injector>(@NonNull InjectionLayer<I extends dev.derklaro.aerogel.Injector> parent)
extends Record
implements InjectionLayer<I>
An injection layer which delegates all calls to the parent layer, but throwing an exception if there is a try to
close the layer.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull InjectionLayer<I> The field for theparentrecord component.Fields inherited from interface eu.cloudnetservice.driver.inject.InjectionLayer
AUTO_CONFIGURE_FILE_NAME_FORMAT -
Constructor Summary
ConstructorsConstructorDescriptionUncloseableInjectionLayer(@NonNull InjectionLayer<I> parent) Creates an instance of aUncloseableInjectionLayerrecord class. -
Method Summary
Modifier and TypeMethodDescriptionMakes this injection layer not closeable, returning the same layer if it is already not closeable.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 a dynamic binding into the underlying injector.voidInstalls the uninstalled binding into the underlying injector.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 binding key.<T> @UnknownNullability TConvince method to create or get the instance of the given class type.<T> @UnknownNullability Tinstance(@NonNull Class<T> type, @NonNull UnaryOperator<dev.derklaro.aerogel.InjectionRequest<T>> decorator) Convince method to create or get the instance of the given type, while allowing to specifically influence the injection context.name()Get the name of this injection layer, for identification purposes.parent()Returns the value of theparentrecord component.Registers this injection layer to the injection layer registry.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
parent
The field for theparentrecord component.
-
-
Constructor Details
-
UncloseableInjectionLayer
UncloseableInjectionLayer(@NonNull @NonNull InjectionLayer<I> parent) Creates an instance of aUncloseableInjectionLayerrecord class.- Parameters:
parent- the value for theparentrecord component
-
-
Method Details
-
name
Get the name of this injection layer, for identification purposes. The names boot and ext are reserved for internal use only.- Specified by:
namein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Specified by:
namein interfaceNamed- Returns:
- the name of this layer.
-
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
public <T> @UnknownNullability T instance(@NonNull @NonNull dev.derklaro.aerogel.binding.key.BindingKey<T> bindingKey) Convince method to create or get the instance of the given binding key.- Specified by:
instancein interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Type Parameters:
T- the type of the return value modeled by the given binding key.- Parameters:
bindingKey- the binding key for the instance to resolve.- Returns:
- the constructed instance of the class type, may be null.
-
instance
public <T> @UnknownNullability T instance(@NonNull @NonNull Class<T> type, @NonNull @NonNull UnaryOperator<dev.derklaro.aerogel.InjectionRequest<T>> decorator) 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.decorator- the decorator for the injection request.- Returns:
- the constructed instance of the class type, may be null.
-
install
Installs the uninstalled binding into the underlying injector.- Specified by:
installin interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Parameters:
binding- the binding to install.
-
install
Installs a dynamic binding into the underlying injector. The dynamic binding can be used to provide bindings based on the presence of annotations and other matching criteria. Dynamic bindings have a lower priority thanUninstalledBinding.- Specified by:
installin interfaceInjectionLayer<I extends dev.derklaro.aerogel.Injector>- Parameters:
binding- the dynamic binding 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
-
hashCode
-
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). -
parent
-