public interface DependencyResolver
Dependency instances by type or name.
Also provides typed access to the instance values directly via getDependencyValue.
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<Dependency> |
getDependency(java.lang.Class<?> type)
Retrieves an optional dependency by its type.
|
java.util.Optional<Dependency> |
getDependency(java.lang.String name)
Retrieves an optional dependency by its registered name.
|
default <T> java.util.Optional<T> |
getDependencyValue(java.lang.Class<T> type)
Retrieves the value of a dependency by type, automatically casting it.
|
default <T> java.util.Optional<T> |
getDependencyValue(java.lang.String name,
java.lang.Class<T> type)
Retrieves the value of a dependency by name, automatically casting it.
|
default Dependency |
getRequiredDependency(java.lang.Class<?> type)
Retrieves a dependency by type or throws
NotFoundDependencyException if not found. |
default Dependency |
getRequiredDependency(java.lang.String name)
Retrieves a dependency by name or throws
NotFoundDependencyException if not found. |
default <T> T |
getRequiredDependencyValue(java.lang.Class<T> type)
Retrieves a dependency value by type or throws
NotFoundDependencyException if not found. |
default <T> T |
getRequiredDependencyValue(java.lang.String name,
java.lang.Class<T> type)
Retrieves a dependency value by name or throws
NotFoundDependencyException if not found. |
java.util.Optional<Dependency> getDependency(java.lang.Class<?> type)
type - the class type of the dependencyOptional containing the dependency if found, otherwise emptyjava.util.Optional<Dependency> getDependency(java.lang.String name)
name - the name under which the dependency was registeredOptional containing the dependency if found, otherwise emptydefault Dependency getRequiredDependency(java.lang.Class<?> type)
NotFoundDependencyException if not found.type - the class type of the dependencyDependency instancedefault Dependency getRequiredDependency(java.lang.String name)
NotFoundDependencyException if not found.name - the name of the dependencyDependency instancedefault <T> java.util.Optional<T> getDependencyValue(java.lang.Class<T> type)
T - the type of the dependency valuetype - the class type of the dependencyOptional containing the instance if found and castable, otherwise emptydefault <T> java.util.Optional<T> getDependencyValue(java.lang.String name,
java.lang.Class<T> type)
T - the type of the dependency valuename - the name of the dependencytype - the expected type of the instanceOptional containing the instance if found and castable, otherwise emptydefault <T> T getRequiredDependencyValue(java.lang.Class<T> type)
NotFoundDependencyException if not found.T - the type of the dependency valuetype - the expected type of the instancedefault <T> T getRequiredDependencyValue(java.lang.String name,
java.lang.Class<T> type)
NotFoundDependencyException if not found.T - the type of the dependency valuename - the name of the dependencytype - the expected type of the instance