- All Superinterfaces:
Prototype.Api
- All Known Implementing Classes:
Dependency.BuilderBase.DependencyImpl
Dependency metadata.
Dependencies can be injected into a service through a constructor. We also support field injection, though it is not recommended due to complicated unit testing.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Fluent API builder forDependency
.static class
Dependency.BuilderBase<BUILDER extends Dependency.BuilderBase<BUILDER,
PROTOTYPE>, PROTOTYPE extends Dependency> Fluent API builder base forDependency
. -
Method Summary
Modifier and TypeMethodDescriptionaccess()
The access modifier on the injection point/receiver.The annotations on this element.static Dependency.Builder
builder()
Create a new fluent API builder to customize configuration.static Dependency.Builder
builder
(Dependency instance) Create a new fluent API builder from an existing instance.Cardinality of this dependency.contract()
Each dependency ia a specific contract.GenericType
<?> Generic type equivalent toDependencyBlueprint.contract()
.static Dependency
create()
Create a new instance with default values.Descriptor declaring this dependency.Field name that declares this dependency in theDependencyBlueprint.descriptor()
.Kind of element we inject into (constructor, field, method).boolean
Whether this dependency usesServiceInstance
.boolean
Whether this dependency uses aSupplier
instead of a direct instance.method()
Top level method that declares this method.name()
Name of the constructor parameter.The qualifier type annotations on this element.service()
Type name of the service that uses this dependency.typeName()
Type of the dependency (exact parameter type with all generics).
-
Method Details
-
builder
Create a new fluent API builder to customize configuration.- Returns:
- a new builder
-
builder
Create a new fluent API builder from an existing instance.- Parameters:
instance
- an existing instance used as a base for the builder- Returns:
- a builder based on an instance
-
create
Create a new instance with default values.- Returns:
- a new instance
-
service
TypeName service()Type name of the service that uses this dependency.- Returns:
- the service declaring this dependency
-
name
String name()Name of the constructor parameter.- Returns:
- unique name of the parameter
-
contract
TypeName contract()Each dependency ia a specific contract. Each service provides one or more contracts for dependencies. For example forList<MyService>
, the contract isMyService
.- Returns:
- contract of the service we depend on
-
contractType
GenericType<?> contractType()Generic type equivalent toDependencyBlueprint.contract()
. We need both, to prevent reflection at runtime.- Returns:
- generic type of the dependency
-
descriptor
TypeName descriptor()Descriptor declaring this dependency. Descriptor is always public.- Returns:
- descriptor
-
descriptorConstant
String descriptorConstant()Field name that declares this dependency in theDependencyBlueprint.descriptor()
. Can be used for code generation. This field is always a public constant.- Returns:
- field that has the dependency on the descriptor type
-
typeName
TypeName typeName()Type of the dependency (exact parameter type with all generics).- Returns:
- type of the dependency as
TypeName
-
elementKind
ElementKind elementKind()Kind of element we inject into (constructor, field, method).- Returns:
- element kind (for parameters, the containing element)
-
qualifiers
The qualifier type annotations on this element.- Returns:
- the qualifier type annotations on this element
-
access
AccessModifier access()The access modifier on the injection point/receiver. Defaults toAccessModifier.PACKAGE_PRIVATE
.- Returns:
- the access
-
annotations
Set<Annotation> annotations()The annotations on this element.- Returns:
- the annotations on this element
-
method
Top level method that declares this method. This is to provide information about overridden methods, as we should only inject such methods once.- Returns:
- unique identification of a declaring method
-
cardinality
DependencyCardinality cardinality()Cardinality of this dependency. Defaults toDependencyCardinality.REQUIRED
.- Returns:
- cardinality of this dependency
-
isServiceInstance
boolean isServiceInstance()Whether this dependency usesServiceInstance
. Defaults tofalse
, which means the service is injected via its contract.- Returns:
- whether the dependency is declared as a
ServiceInstance
-
isSupplier
boolean isSupplier()Whether this dependency uses aSupplier
instead of a direct instance. This defaults tofalse
.- Returns:
- whether the dependency injection point uses a supplier
-