oracle.dbtools.plugin.api.di

## Class Instances.Builder

- java.lang.Object
- - oracle.dbtools.plugin.api.di.Instances.Builder

- All Implemented Interfaces:
    InstanceLocator
  Enclosing class:
    Instances

      public static class Instances.Builder
      extends Object
      implements InstanceLocator

  Build `Instances` instances
  Author:
    cdivilly

- - ### Field Summary

    - ### Fields inherited from interface oracle.dbtools.plugin.api.di.InstanceLocator

      `INSTANCE_LOCATOR_ATTRIBUTE, INSTANTIATOR_TYPE_SUFFIX`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> Instances.Builder` | `add(Class<T> service, T instance)` Add an instance of a service
    `<T> Instances.Builder` | `add(TypeQualifier<T> service, T instance)` Add an instance of a service
    `Instances` | `build()` Build the `Instances` instance
    `Instances.Builder` | `clear()` Clear all instances
    `Instances.Builder` | `merge(Instances other, boolean overwrite)` Merge the specified set of instances into this set, overwriting any existing instances with the specified values
    `Instances.Builder` | `remove(Class<?> type)` Remove all providers of the specified type
    `<T> Instances.Builder` | `remove(TypeQualifier<T> service)` Remove all providers of the specified service
    `<T> InstanceProvider<T>` | `select(TypeQualifier<T> service)` Select all services matching the specified `TypeQualifier`
    `<T> Instances.Builder` | `set(Class<T> service, T instance)` Set the sole provider of the specified service
    `Instances.Builder` | `set(TypeQualifier<?> service, InstanceProvider<?> provider)` Set the sole `InstanceProvider` for the specified service
    `<T> Instances.Builder` | `set(TypeQualifier<T> qualifier, T instance)` Set the sole implementation of the specified service
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface oracle.dbtools.plugin.api.di.InstanceLocator

      `empty, select, select`

- - ### Method Detail

    - #### add

          public <T> Instances.Builder add(Class<T> service,
                                           T instance)

      Add an instance of a service
      Type Parameters:
        `T` - The type of the service
      Parameters:
        `service` - The type of the service
        `instance` - The implementation of the service
      Returns:
        self

    - #### add

          public <T> Instances.Builder add(TypeQualifier<T> service,
                                           T instance)

      Add an instance of a service
      Type Parameters:
        `T` - The type of the service
      Parameters:
        `service` - The qualified service type
        `instance` - The implementation of the service
      Returns:
        self

    - #### build

          public Instances build()

      Build the `Instances` instance
      Returns:
        Immutable `Instances` instance

    - #### clear

          public Instances.Builder clear()

      Clear all instances
      Returns:
        self

    - #### merge

          public Instances.Builder merge(Instances other,
                                         boolean overwrite)

      Merge the specified set of instances into this set, overwriting any existing instances with the specified values
      Parameters:
        `other` - The values to merge into the set
        `overwrite` - Determines the merging behavior. If true then existing matches are replaced with the specified values, if false, existing values are retained, only values not already present are added
      Returns:
        self

    - #### remove

          public Instances.Builder remove(Class<?> type)

      Remove all providers of the specified type
      Parameters:
        `type` - The service type to remove
      Returns:
        self

    - #### remove

          public <T> Instances.Builder remove(TypeQualifier<T> service)

      Remove all providers of the specified service
      Type Parameters:
        `T` - The type of the service
      Parameters:
        `service` - The qualified service
      Returns:
        self

    - #### select

          public <T> InstanceProvider<T> select(TypeQualifier<T> service)

      Description copied from interface: `InstanceLocator`
      Select all services matching the specified `TypeQualifier`
      Specified by:
        `select` in interface `InstanceLocator`
      Type Parameters:
        `T` - The type of the service to locate
      Parameters:
        `service` - The qualifier that constrains which implementation to match
      Returns:
        `InstanceProvider` for the specified type and qualifier. This value is never null.

    - #### set

          public <T> Instances.Builder set(Class<T> service,
                                           T instance)

      Set the sole provider of the specified service
      Type Parameters:
        `T` - The type of the service
      Parameters:
        `service` - The type of the service
        `instance` - The implementation of the service
      Returns:
        self

    - #### set

          public Instances.Builder set(TypeQualifier<?> service,
                                       InstanceProvider<?> provider)

      Set the sole `InstanceProvider` for the specified service
      Parameters:
        `service` - The qualified service
        `provider` - The provider of the service
      Returns:
        self

    - #### set

          public <T> Instances.Builder set(TypeQualifier<T> qualifier,
                                           T instance)

      Set the sole implementation of the specified service
      Type Parameters:
        `T` - The type of the service
      Parameters:
        `qualifier` - The qualified service
        `instance` - The implementation of the service
      Returns:
        self

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2010, 2022, Oracle and/or its affiliates.