|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unkrig.commons.lang.protocol.ProducerUtil
public final class ProducerUtil
Various Producer-related utility methods.
| Method Summary | ||
|---|---|---|
static
|
asProducer(ProducerWhichThrows<? extends T,? extends java.lang.RuntimeException> source)
Converts a {@link ProducerWhichThrows ProducerWhichThrows<? |
|
static
|
asProducerWhichThrows(Producer<? extends T> source)
Converts a {@link Producer Producer<? |
|
static
|
constantProducer(T constant)
|
|
static Producer<java.lang.Boolean> |
every(long interval)
Returns a Producer<Boolean> who's first evaluation result is true, and each following result is
true iff the last true result was returned at least the given interval milliseconds ago. |
|
static
|
fromCollection(java.util.Collection<T> delegate)
Produces the elements of the delegate collection, in its iteration order, or null iff the
collection is empty. |
|
static
|
fromElements(T... elements)
|
|
static
|
fromIndexTransformer(Transformer<java.lang.Integer,T> indexTransformer)
Produces objects based on the number of preceding invocations, i.e. the indexTransformer is invoked
with subjects '0', '1', '2', ... |
|
static
|
fromIndexTransformer(TransformerWhichThrows<java.lang.Integer,T,EX> indexTransformer)
Produces objects based on the number of preceding invocations, i.e. the indexTransformer is invoked
with subjects '0', '1', '2', ... |
|
static
|
fromIterator(java.util.Iterator<T> iterator)
Produces the products of the iterator, or null iff the iterator has no more elements. |
|
static Producer<java.lang.Byte> |
randomByteProducer(long seed)
|
|
static
|
sparingProducer(Producer<T> delegate,
Predicate<ST> condition,
ST subject)
The returned Producer calls the delegate iff the condition returns true,
otherwise it returns the previous product of the delegate, or null iff the delegate has
not yet been called. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T,ST> Producer<T> sparingProducer(Producer<T> delegate,
Predicate<ST> condition,
ST subject)
Producer calls the delegate iff the condition returns true,
otherwise it returns the previous product of the delegate, or null iff the delegate has
not yet been called.
subject - The subject argument for the conditionpublic static Producer<java.lang.Boolean> every(long interval)
Producer<Boolean> who's first evaluation result is true, and each following result is
true iff the last true result was returned at least the given interval milliseconds ago.
In other words, the interval between two returned true values is never shorter than interval
milliseconds.
public static <T,EX extends java.lang.Throwable> ProducerWhichThrows<T,EX> asProducerWhichThrows(Producer<? extends T> source)
Producer<? extends TT> (the "source") into a ProducerWhichThrows<TT, TE> (the "target"), which is always possible.
T - The element typeEX - The target producer's exceptionpublic static <T> Producer<T> asProducer(ProducerWhichThrows<? extends T,? extends java.lang.RuntimeException> source)
ProducerWhichThrows<? extends T, ? extends RuntimeException> (the
"source") into a Producer<T> (the "target"), which is always possible.
T - The element typepublic static <T> Producer<T> fromElements(T... elements)
Producer that produced the given elementspublic static <T> Producer<T> fromCollection(java.util.Collection<T> delegate)
delegate collection, in its iteration order, or null iff the
collection is empty. The elements are removed from the collection as they are produced.
public static <T> Producer<T> fromIterator(java.util.Iterator<T> iterator)
iterator, or null iff the iterator has no more elements.
public static <T> Producer<T> fromIndexTransformer(Transformer<java.lang.Integer,T> indexTransformer)
indexTransformer is invoked
with subjects '0', '1', '2', ...
public static <T,EX extends java.lang.Exception> ProducerWhichThrows<T,EX> fromIndexTransformer(TransformerWhichThrows<java.lang.Integer,T,EX> indexTransformer)
indexTransformer is invoked
with subjects '0', '1', '2', ...
public static Producer<java.lang.Byte> randomByteProducer(long seed)
new java.util.Random(seed).nextInt(0x100)public static <T> Producer<T> constantProducer(T constant)
constant
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||