Interface ServiceDependency<V>

All Superinterfaces:
Consumer<ServiceBuilder<?>>, Dependency<ServiceBuilder<?>,V>, Supplier<V>
All Known Implementing Classes:
ServiceDependency.DefaultServiceDependency, ServiceDependency.SimpleServiceDependency, ServiceDependency.SuppliedServiceDependency

public interface ServiceDependency<V> extends Dependency<ServiceBuilder<?>,V>
Encapsulates a dependency on a service value.
Author:
Paul Ferraro
  • Method Details

    • andThen

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

      default <R> ServiceDependency<R> map(Function<V,R> mapper)
      Description copied from interface: Dependency
      Returns a dependency whose value is the result of applying the specified mapping function.
      Specified by:
      map in interface Dependency<ServiceBuilder<?>,V>
      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.
    • combine

      default <T, R> ServiceDependency<R> combine(Dependency<ServiceBuilder<?>,T> dependency, BiFunction<V,T,R> mapper)
      Description copied from interface: Dependency
      Returns a dependency that combines this dependency with the specified dependency, whose value is determined by the specified mapping function.
      Specified by:
      combine in interface Dependency<ServiceBuilder<?>,V>
      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.
    • empty

      static <V> ServiceDependency<V> empty()
      Returns an empty pseudo-dependency whose Supplier.get() returns null.
      Type Parameters:
      V - the value type
      Returns:
      an empty service dependency
    • of

      static <V> ServiceDependency<V> of(V value)
      Returns a pseudo-dependency whose Supplier.get() returns the specified value.
      Type Parameters:
      V - the value type
      Parameters:
      value - a service value
      Returns:
      a pseudo-dependency whose Supplier.get() returns the specified value.
    • from

      static <V> ServiceDependency<V> from(Supplier<V> supplier)
      Returns a pseudo-dependency whose Supplier.get() returns the value from the specified supplier.
      Type Parameters:
      V - the value type
      Parameters:
      supplier - a service value supplier
      Returns:
      a pseudo-dependency whose Supplier.get() returns the value from the specified supplier.
      Throws:
      NullPointerException - if supplier was null
    • on

      static <V> ServiceDependency<V> on(ServiceName name)
      Returns a dependency on the service with the specified name.
      Type Parameters:
      V - the dependency type
      Parameters:
      name - a service name
      Returns:
      a service dependency