Class Dependency.BuilderBase<BUILDER extends Dependency.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends Dependency>

java.lang.Object
io.helidon.service.registry.Dependency.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
Dependency.Builder
Enclosing interface:
Dependency

public abstract static class Dependency.BuilderBase<BUILDER extends Dependency.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends Dependency> extends Object implements Prototype.Builder<BUILDER,PROTOTYPE>
Fluent API builder base for Dependency.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(Dependency prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(Dependency.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • service

      public BUILDER service(TypeName service)
      Type name of the service that uses this dependency.
      Parameters:
      service - the service declaring this dependency
      Returns:
      updated builder instance
      See Also:
    • service

      public BUILDER service(Consumer<TypeName.Builder> consumer)
      Type name of the service that uses this dependency.
      Parameters:
      consumer - consumer of builder for the service declaring this dependency
      Returns:
      updated builder instance
      See Also:
    • service

      public BUILDER service(Supplier<? extends TypeName> supplier)
      Type name of the service that uses this dependency.
      Parameters:
      supplier - supplier of the service declaring this dependency
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name of the constructor parameter.
      Parameters:
      name - unique name of the parameter
      Returns:
      updated builder instance
      See Also:
    • contract

      public BUILDER 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.
      Parameters:
      contract - contract of the service we depend on
      Returns:
      updated builder instance
      See Also:
    • contract

      public BUILDER contract(Consumer<TypeName.Builder> consumer)
      Each dependency ia a specific contract. Each service provides one or more contracts for dependencies. For example for List<MyService>, the contract is MyService.
      Parameters:
      consumer - consumer of builder for contract of the service we depend on
      Returns:
      updated builder instance
      See Also:
    • contract

      public BUILDER contract(Supplier<? extends TypeName> supplier)
      Each dependency ia a specific contract. Each service provides one or more contracts for dependencies. For example for List<MyService>, the contract is MyService.
      Parameters:
      supplier - supplier of contract of the service we depend on
      Returns:
      updated builder instance
      See Also:
    • contractType

      public BUILDER contractType(GenericType<?> contractType)
      Generic type equivalent to DependencyBlueprint.contract(). We need both, to prevent reflection at runtime.
      Parameters:
      contractType - generic type of the dependency
      Returns:
      updated builder instance
      See Also:
    • descriptor

      public BUILDER descriptor(TypeName descriptor)
      Descriptor declaring this dependency. Descriptor is always public.
      Parameters:
      descriptor - descriptor
      Returns:
      updated builder instance
      See Also:
    • descriptor

      public BUILDER descriptor(Consumer<TypeName.Builder> consumer)
      Descriptor declaring this dependency. Descriptor is always public.
      Parameters:
      consumer - consumer of builder for descriptor
      Returns:
      updated builder instance
      See Also:
    • descriptor

      public BUILDER descriptor(Supplier<? extends TypeName> supplier)
      Descriptor declaring this dependency. Descriptor is always public.
      Parameters:
      supplier - supplier of descriptor
      Returns:
      updated builder instance
      See Also:
    • descriptorConstant

      public BUILDER 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.
      Parameters:
      descriptorConstant - field that has the dependency on the descriptor type
      Returns:
      updated builder instance
      See Also:
    • typeName

      public BUILDER typeName(TypeName typeName)
      Type of the dependency (exact parameter type with all generics).
      Parameters:
      typeName - type of the dependency as TypeName
      Returns:
      updated builder instance
      See Also:
    • typeName

      public BUILDER typeName(Consumer<TypeName.Builder> consumer)
      Type of the dependency (exact parameter type with all generics).
      Parameters:
      consumer - consumer of builder for type of the dependency as TypeName
      Returns:
      updated builder instance
      See Also:
    • typeName

      public BUILDER typeName(Supplier<? extends TypeName> supplier)
      Type of the dependency (exact parameter type with all generics).
      Parameters:
      supplier - supplier of type of the dependency as TypeName
      Returns:
      updated builder instance
      See Also:
    • elementKind

      public BUILDER elementKind(ElementKind elementKind)
      Kind of element we inject into (constructor, field, method).
      Parameters:
      elementKind - element kind (for parameters, the containing element)
      Returns:
      updated builder instance
      See Also:
    • qualifiers

      public BUILDER qualifiers(Set<? extends Qualifier> qualifiers)
      The qualifier type annotations on this element.
      Parameters:
      qualifiers - the qualifier type annotations on this element
      Returns:
      updated builder instance
      See Also:
    • addQualifiers

      public BUILDER addQualifiers(Set<? extends Qualifier> qualifiers)
      The qualifier type annotations on this element.
      Parameters:
      qualifiers - the qualifier type annotations on this element
      Returns:
      updated builder instance
      See Also:
    • addQualifier

      public BUILDER addQualifier(Qualifier qualifier)
      The qualifier type annotations on this element.
      Parameters:
      qualifier - the qualifier type annotations on this element
      Returns:
      updated builder instance
      See Also:
    • addQualifier

      public BUILDER addQualifier(Consumer<Qualifier.Builder> consumer)
      The qualifier type annotations on this element.
      Parameters:
      consumer - the qualifier type annotations on this element
      Returns:
      updated builder instance
      See Also:
    • access

      public BUILDER access(AccessModifier access)
      The access modifier on the injection point/receiver. Defaults to AccessModifier.PACKAGE_PRIVATE.
      Parameters:
      access - the access
      Returns:
      updated builder instance
      See Also:
    • annotations

      public BUILDER annotations(Set<? extends Annotation> annotations)
      The annotations on this element.
      Parameters:
      annotations - the annotations on this element
      Returns:
      updated builder instance
      See Also:
    • addAnnotations

      public BUILDER addAnnotations(Set<? extends Annotation> annotations)
      The annotations on this element.
      Parameters:
      annotations - the annotations on this element
      Returns:
      updated builder instance
      See Also:
    • addAnnotation

      public BUILDER addAnnotation(Annotation annotation)
      The annotations on this element.
      Parameters:
      annotation - the annotations on this element
      Returns:
      updated builder instance
      See Also:
    • addAnnotation

      public BUILDER addAnnotation(Consumer<Annotation.Builder> consumer)
      The annotations on this element.
      Parameters:
      consumer - the annotations on this element
      Returns:
      updated builder instance
      See Also:
    • clearMethod

      public BUILDER clearMethod()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • method

      public BUILDER method(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.
      Parameters:
      method - unique identification of a declaring method
      Returns:
      updated builder instance
      See Also:
    • cardinality

      public BUILDER cardinality(DependencyCardinality cardinality)
      Cardinality of this dependency. Defaults to DependencyCardinality.REQUIRED.
      Parameters:
      cardinality - cardinality of this dependency
      Returns:
      updated builder instance
      See Also:
    • isServiceInstance

      public BUILDER isServiceInstance(boolean isServiceInstance)
      Whether this dependency uses ServiceInstance. Defaults to false, which means the service is injected via its contract.
      Parameters:
      isServiceInstance - whether the dependency is declared as a ServiceInstance
      Returns:
      updated builder instance
      See Also:
    • isSupplier

      public BUILDER isSupplier(boolean isSupplier)
      Whether this dependency uses a Supplier instead of a direct instance. This defaults to false.
      Parameters:
      isSupplier - whether the dependency injection point uses a supplier
      Returns:
      updated builder instance
      See Also:
    • service

      public Optional<TypeName> service()
      Type name of the service that uses this dependency.
      Returns:
      the service
    • name

      public Optional<String> name()
      Name of the constructor parameter.
      Returns:
      the name
    • contract

      public Optional<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:
      the contract
    • contractType

      public GenericType<?> contractType()
      Generic type equivalent to DependencyBlueprint.contract(). We need both, to prevent reflection at runtime.
      Returns:
      the contract type
    • descriptor

      public Optional<TypeName> descriptor()
      Descriptor declaring this dependency. Descriptor is always public.
      Returns:
      the descriptor
    • descriptorConstant

      public Optional<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:
      the descriptor constant
    • typeName

      public Optional<TypeName> typeName()
      Type of the dependency (exact parameter type with all generics).
      Returns:
      the type name
    • elementKind

      public ElementKind elementKind()
      Kind of element we inject into (constructor, field, method).
      Returns:
      the element kind
    • qualifiers

      public Set<Qualifier> qualifiers()
      The qualifier type annotations on this element.
      Returns:
      the qualifiers
    • access

      public AccessModifier access()
      The access modifier on the injection point/receiver. Defaults to AccessModifier.PACKAGE_PRIVATE.
      Returns:
      the access
    • annotations

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

      public 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:
      the method
    • cardinality

      public DependencyCardinality cardinality()
      Cardinality of this dependency. Defaults to DependencyCardinality.REQUIRED.
      Returns:
      the cardinality
    • isServiceInstance

      public boolean isServiceInstance()
      Whether this dependency uses ServiceInstance. Defaults to false, which means the service is injected via its contract.
      Returns:
      the is service instance
    • isSupplier

      public boolean isSupplier()
      Whether this dependency uses a Supplier instead of a direct instance. This defaults to false.
      Returns:
      the is supplier
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.