Package org.ojalgo.type.function
Interface AutoSupplier<T>
-
- All Superinterfaces:
java.lang.AutoCloseable
,AutoFunctional
,java.lang.Iterable<T>
,java.util.function.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 java.lang.AutoCloseable, java.util.function.Supplier<T>, AutoFunctional, java.lang.Iterable<T>
Utilities forAutoCloseable
Supplier
:s
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
close()
default int
drainTo(java.util.Collection<? super T> container, int maxElements)
static <T> AutoSupplier<T>
empty()
default T
get()
default java.util.Iterator<T>
iterator()
static <T> AutoSupplier<T>
managed(java.lang.String name, java.util.function.Supplier<T> supplier)
Will create a JMX bean, with the given name, that keeps track of the supplier's throughput.static <T> AutoSupplier<T>
managed(Throughput manager, java.util.function.Supplier<T> supplier)
If you want that throughput manager to be registered as a JMX bean, that's up to you.static <T,U>
AutoSupplier<U>mapped(java.util.function.Supplier<T> supplier, java.util.function.Function<T,U> mapper)
Get something and map/transform before returning itstatic <T,U>
AutoSupplier<U>mapped(java.util.function.Supplier<T> supplier, java.util.function.Predicate<T> filter, java.util.function.Function<T,U> mapper)
Get something, that passes the test, and map/transform before returning itdefault void
processAll(java.util.function.Consumer<T> processor)
static <T> AutoSupplier<T>
queued(java.util.concurrent.ExecutorService executor, java.util.concurrent.BlockingQueue<T> queue, java.util.function.Supplier<T>... suppliers)
Multiple suppliers supply to a queue, then you get from that queue.T
read()
static <T> AutoSupplier<T>
sequenced(java.util.concurrent.BlockingQueue<? extends java.util.function.Supplier<T>> sources)
static <S,T>
AutoSupplier<T>sequenced(java.util.concurrent.BlockingQueue<S> sources, java.util.function.Function<S,? extends java.util.function.Supplier<T>> factory)
Create anAutoSupplier
that will supply items from the containers, one after the other, until all containers are empty.
-
-
-
Method Detail
-
empty
static <T> AutoSupplier<T> empty()
-
managed
static <T> AutoSupplier<T> managed(java.lang.String name, java.util.function.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, java.util.function.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(java.util.function.Supplier<T> supplier, java.util.function.Function<T,U> mapper)
Get something and map/transform before returning it
-
mapped
static <T,U> AutoSupplier<U> mapped(java.util.function.Supplier<T> supplier, java.util.function.Predicate<T> filter, java.util.function.Function<T,U> mapper)
Get something, that passes the test, and map/transform before returning it
-
queued
static <T> AutoSupplier<T> queued(java.util.concurrent.ExecutorService executor, java.util.concurrent.BlockingQueue<T> queue, java.util.function.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(java.util.concurrent.BlockingQueue<? extends java.util.function.Supplier<T>> sources)
-
sequenced
static <S,T> AutoSupplier<T> sequenced(java.util.concurrent.BlockingQueue<S> sources, java.util.function.Function<S,? extends java.util.function.Supplier<T>> factory)
Create anAutoSupplier
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 aFile
)T
- The supplier item type (what do the files contain?)- Parameters:
sources
- A set of item containers (could be a set ofFile
: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 java.lang.Exception
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
-
drainTo
default int drainTo(java.util.Collection<? super T> container, int maxElements)
-
iterator
default java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
processAll
default void processAll(java.util.function.Consumer<T> processor)
-
read
T read()
-
-