Interface Dependency<B extends ServiceBuilder<?>,V>

All Superinterfaces:
Consumer<B>, Supplier<V>
All Known Subinterfaces:
ServiceDependency<V>, ServiceDependency<V>
All Known Implementing Classes:
Dependency.AbstractDependency, Dependency.DefaultDependency, Dependency.SimpleDependency, Dependency.SuppliedDependency, ServiceDependency.AbstractServiceDependency, ServiceDependency.DefaultServiceDependency, ServiceDependency.DefaultServiceDependency, ServiceDependency.SimpleServiceDependency, ServiceDependency.SimpleServiceDependency, ServiceDependency.SuppliedServiceDependency, ServiceDependency.SuppliedServiceDependency

public interface Dependency<B extends ServiceBuilder<?>,V> extends Consumer<B>, Supplier<V>
Encapsulates logic for registering a value providing dependency with a service builder.
Author:
Paul Ferraro
  • Method Details

    • andThen

      default Dependency<B,V> andThen(Consumer<? super B> after)
      Specified by:
      andThen in interface Consumer<B extends ServiceBuilder<?>>
    • map

      default <R> Dependency<B,R> map(Function<V,R> mapper)
      Returns a dependency whose value is the result of applying the specified mapping function.
      Type Parameters:
      R - the mapped value type
      Parameters:
      mapper - a mapping function
      Returns:
      a dependency whose value is the result of applying the specified mapping function.
      Throws:
      NullPointerException - if mapper was null
    • combine

      default <T, R> Dependency<B,R> combine(Dependency<B,T> dependency, BiFunction<V,T,R> mapper)
      Returns a dependency that combines this dependency with the specified dependency, whose value is determined by the specified mapping function.
      Type Parameters:
      T - the other dependency type
      R - the mapped value type
      Parameters:
      dependency - another dependency
      mapper - a mapping function
      Returns:
      a dependency that combines this dependency with the specified dependency, whose value is determined by the specified mapping function.
      Throws:
      NullPointerException - if dependency or mapper were null.
    • isEmpty

      default boolean isEmpty()
      Indicates whether this dependency will never provide a value.
      Returns:
      true, if this dependency will not provide a value, false otherwise.
    • isPresent

      default boolean isPresent()
      Indicates whether this dependency will provide a value. This method is the direct inverse of isEmpty().
      Returns:
      true, if this dependency will provide a value, false otherwise.