Interface Dependency

All Superinterfaces:
Prototype.Api
All Known Implementing Classes:
Dependency.BuilderBase.DependencyImpl

public interface Dependency extends Prototype.Api
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:
  • Method Details

    • builder

      static Dependency.Builder builder()
      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      static Dependency.Builder builder(Dependency instance)
      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

      static Dependency 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 for List<MyService>, the contract is MyService.
      Returns:
      contract of the service we depend on
    • contractType

      GenericType<?> contractType()
      Generic type equivalent to DependencyBlueprint.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 the DependencyBlueprint.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

      Set<Qualifier> 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 to AccessModifier.PACKAGE_PRIVATE.
      Returns:
      the access
    • annotations

      Set<Annotation> annotations()
      The annotations on this element.
      Returns:
      the annotations on this element
    • method

      Optional<String> 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 to DependencyCardinality.REQUIRED.
      Returns:
      cardinality of this dependency
    • isServiceInstance

      boolean isServiceInstance()
      Whether this dependency uses ServiceInstance. Defaults to false, 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 a Supplier instead of a direct instance. This defaults to false.
      Returns:
      whether the dependency injection point uses a supplier