|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tapestry5.func.F
public class F
Functional operations on collections with generics support. The core interface is Flow to which operations
and transformations
(in terms of Predicates, Mappers and Reducers) to create new Flows. Flows are initially
created
using flow(Collection) and flow(Object...).
F will be used a bit, thus it has a short name (for those who don't like static imports). It provides a base set of Predicate, Mapper and Reducer factories. A good development pattern for applications is to provide a similar, application-specific, set of such factories.
| Field Summary | |
|---|---|
static Mapper2<java.lang.Integer,java.lang.Integer,java.lang.Integer> |
ADD_INTS
|
static Reducer<java.lang.Integer,java.lang.Integer> |
SUM_INTS
|
| Constructor Summary | |
|---|---|
F()
|
|
| Method Summary | ||
|---|---|---|
static
|
addToCollection(java.util.Collection<T> coll)
|
|
static
|
always(T fixedResult)
Returns a Mapper that ignores its input value and always returns a predetermined result. |
|
static Predicate<java.lang.Number> |
eq(long value)
|
|
static
|
eql(T value)
|
|
static
|
flow(java.util.Collection<T> values)
Extracts the values from the collection to form a Flow. |
|
static
|
flow(java.lang.Iterable<T> iterable)
Creates a lazy Flow from the Iterator obtained from the iterable. |
|
static
|
flow(T... values)
Creates a new Flow from the values. |
|
static Predicate<java.lang.Number> |
gt(long value)
|
|
static Predicate<java.lang.Number> |
gteq(long value)
|
|
static
|
identity()
The identity mapper simply returns the input unchanged. |
|
static
|
isNull()
|
|
static
|
iterate(T initial,
Mapper<T,T> mapper)
Creates a lazy, infinte Flow consisting of the initial value, then the result of passing the initial value through the Mapper, and so forth, which each step value passed through the mapper to form the next step value. |
|
static
|
lazy(LazyFunction<T> function)
Creates a Flow from a lazy function. |
|
static Predicate<java.lang.Number> |
lt(long value)
|
|
static Predicate<java.lang.Number> |
lteq(long value)
|
|
static Predicate<java.lang.Number> |
neq(long value)
|
|
static
|
notNull()
|
|
static Flow<java.lang.Integer> |
range(int lower,
int upper)
Creates a lazy Flow that returns integers in the given range. |
|
static
|
select(Predicate<? super S> predicate,
Mapper<S,T> ifAccepted)
Override of select(Predicate, Mapper, Mapper) where rejected values are replaced with null. |
|
static
|
select(Predicate<? super S> predicate,
Mapper<S,T> ifAccepted,
Mapper<S,T> ifRejected)
Mapper factory that combines a Predicate with two Mappers; evaluating the predicate selects one of the
two mappers. |
|
static
|
select(Predicate<? super S> predicate,
Mapper<S,T> ifAccepted,
T ifRejectedValue)
Override of select(Predicate, Mapper) where rejected values are replaced with a fixed value. |
|
static Flow<java.lang.Integer> |
series(int start,
int delta)
Creates an infinite series of numbers. |
|
static
|
stringValueOf()
|
|
static
|
toPredicate(Mapper<S,java.lang.Boolean> mapper)
Allows a Mapper that maps to boolean to be used as a Predicate. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static Reducer<java.lang.Integer,java.lang.Integer> SUM_INTS
public static Mapper2<java.lang.Integer,java.lang.Integer,java.lang.Integer> ADD_INTS
| Constructor Detail |
|---|
public F()
| Method Detail |
|---|
public static <T> Predicate<T> eql(T value)
public static Predicate<java.lang.Number> eq(long value)
public static Predicate<java.lang.Number> neq(long value)
public static Predicate<java.lang.Number> gt(long value)
public static Predicate<java.lang.Number> gteq(long value)
public static Predicate<java.lang.Number> lt(long value)
public static Predicate<java.lang.Number> lteq(long value)
public static <T> Predicate<T> isNull()
public static <T> Predicate<T> notNull()
public static <T> Mapper<T,java.lang.String> stringValueOf()
public static <S,T> Mapper<S,T> always(T fixedResult)
public static <S,T> Mapper<S,T> select(Predicate<? super S> predicate,
Mapper<S,T> ifAccepted,
Mapper<S,T> ifRejected)
Mappers; evaluating the predicate selects one of the
two mappers.
predicate - evaluated to selected a coercionifAccepted - used when predicate evaluates to trueifRejected - used when predicate evaluates to false
public static <S,T> Mapper<S,T> select(Predicate<? super S> predicate,
Mapper<S,T> ifAccepted)
select(Predicate, Mapper, Mapper) where rejected values are replaced with null.
public static <S,T> Mapper<S,T> select(Predicate<? super S> predicate,
Mapper<S,T> ifAccepted,
T ifRejectedValue)
select(Predicate, Mapper) where rejected values are replaced with a fixed value.
public static <S> Mapper<S,S> identity()
public static <S> Predicate<S> toPredicate(Mapper<S,java.lang.Boolean> mapper)
public static <T> Flow<T> flow(java.util.Collection<T> values)
Flow. The Collection
may change after the Flow is created without affecting the Flow.
public static <T> Flow<T> flow(T... values)
public static <T> Flow<T> flow(java.lang.Iterable<T> iterable)
Iterator obtained from the iterable. The Flow
will be threadsafe as long as the iterable yields a new Iterator on each invocation and the underlying
iterable object is not modified while the Flow is evaluating. In other words, not extremely threadsafe.
public static Flow<java.lang.Integer> range(int lower,
int upper)
lower - start of range (inclusive)upper - end of range (exclusive)public static <T> Flow<T> lazy(LazyFunction<T> function)
Flow from a lazy function.
public static Flow<java.lang.Integer> series(int start,
int delta)
Attempting to get the Flow.count() of the series will form an infinite loop.
public static <T> Flow<T> iterate(T initial,
Mapper<T,T> mapper)
public static <T> Worker<T> addToCollection(java.util.Collection<T> coll)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||