Package com.ssgllc.fish.f.list
Class ListBuilder<U,V>
java.lang.Object
com.ssgllc.fish.f.list.ListBuilder<U,V>
Folds a list to a single value, reached as
f().list.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ListBuilder
public ListBuilder()
-
-
Method Details
-
reduce
Starts a fold over a list. Continue withstartingWithto supply the initial value.This exists because neither dialect has a natural fold: a SpEL expression cannot hold a running variable, so summing or accumulating over a collection needs this shape.
- Parameters:
items- the list to fold; null is treated as empty- Returns:
- a reducer awaiting an initial value
Groovy example:
f().list.reduce(items).startingWith(0)
Returns:
a reducer ready to accumulate
SpEL example:
#f().list.reduce(#lineItems).startingWith(0)
-