Interface AutoSupplier<T>

All Superinterfaces:
AutoCloseable, AutoFunctional, Iterable<T>, Supplier<T>
All Known Subinterfaces:
FromFileReader<T>
All Known Implementing Classes:
DataReader, ManagedSupplier, MappedSupplier, QueuedSupplier, SequencedSupplier, TextLineReader
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 AutoSupplier<T> extends AutoCloseable, Supplier<T>, AutoFunctional, Iterable<T>
Utilities for AutoCloseable Supplier:s
  • Method Details

    • empty

      static <T> AutoSupplier<T> empty()
    • managed

      static <T> AutoSupplier<T> managed(String name, Supplier<T> supplier)
      Will create a JMX bean, with the given name, that keeps track of the supplier's throughput.
    • managed

      static <T> AutoSupplier<T> managed(Throughput manager, Supplier<T> supplier)
      If you want that throughput manager to be registered as a JMX bean, that's up to you.
    • mapped

      static <T, U> AutoSupplier<U> mapped(Supplier<T> supplier, Function<T,U> mapper)
      Get something and map/transform before returning it
    • mapped

      static <T, U> AutoSupplier<U> mapped(Supplier<T> supplier, Predicate<T> filter, Function<T,U> mapper)
      Get something, that passes the test, and map/transform before returning it
    • queued

      static <T> AutoSupplier<T> queued(ExecutorService executor, BlockingQueue<T> queue, Supplier<T>... suppliers)
      Multiple suppliers supply to a queue, then you get from that queue. There will be 1 thread (executor task) per supplier.
    • sequenced

      static <T> AutoSupplier<T> sequenced(BlockingQueue<? extends Supplier<T>> sources)
    • sequenced

      static <S, T> AutoSupplier<T> sequenced(BlockingQueue<S> sources, Function<S,? extends Supplier<T>> factory)
      Create an AutoSupplier that will supply items from the containers, one after the other, until all containers are empty. You can create multiple such suppliers sharing the same queue of containers.
      Type Parameters:
      S - The type of some sort of item container (maybe a File)
      T - The supplier item type (what do the files contain?)
      Parameters:
      sources - A set of item containers (could be a set of File:s)
      factory - A factory method that can take one of the "containers" and return an item supplier.
      Returns:
      A sequenced supplier.
    • close

      default void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • drainTo

      default int drainTo(Collection<? super T> container, int maxElements)
    • get

      default T get()
      Specified by:
      get in interface Supplier<T>
    • iterator

      default Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • processAll

      default void processAll(Consumer<T> processor)
    • read

      T read()