Interface Supplier<T>

Type Parameters:
T - the type of results supplied by this supplier
All Superinterfaces:
Supplier<T>
All Known Subinterfaces:
BooleanSupplier, DoubleSupplier, IntSupplier, LongSupplier
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface
public interface Supplier<T>
extends Supplier<T>
Represents a supplier of results.

There is no requirement that a new or distinct result be returned each time the supplier is invoked.

This is a functional interface whose functional method is get().

Since:
1.8
  • Method Details

    • get

      T get()
      Gets a result.
      Specified by:
      get in interface Supplier<T>
      Returns:
      a result
    • consume

      default Runnable consume​(Consumer<T> consumer)
      Consume a supplier.
      Parameters:
      consumer - The consumer to use in consuming.
      Returns:
      A Runnable which passes the result of this supplier into the given consumer when run.
    • predicate

      default BooleanSupplier predicate​(Predicate<T> functor)
      Lift a supplier.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • map

      default <R> Supplier<R> map​(Function<T,​R> functor)
      Lift a supplier.
      Type Parameters:
      R - The new return type.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A supplier that passes the result of fn through a functor to produce a lifted supplier.
    • mapToDouble

      default DoubleSupplier mapToDouble​(ToDoubleFunction<T> functor)
      Lift a supplier.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToInt

      default IntSupplier mapToInt​(ToIntFunction<T> functor)
      Lift a supplier.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.
    • mapToLong

      default LongSupplier mapToLong​(ToLongFunction<T> functor)
      Lift a supplier.
      Parameters:
      functor - The function to use in lifting.
      Returns:
      A function that passes the result of fn through a functor to produce a lifted function.