public abstract class Fold extends Object implements ValueExpression
ValueExpression implementations of the Fold
operation.
Fold has three operands: values (a ValueExpression),
reducer (a BinaryOperator) and initial (a
ValueExpression). First initial is evaluated. If it
does not return a single value, the final result is an empty list. Next,
values is evaluated and its result is passed to the abstract
prepareValues(ImmutableList) method. The returned list is prefixed
by the value returned by evaluating initial. On this list, the
reducer is applied to the first two values until a single
value remains, which is then returned.
| Modifier and Type | Field and Description |
|---|---|
ValueExpression |
initial |
BinaryOperator<ValueExpression> |
reducer |
ValueExpression |
values |
| Constructor and Description |
|---|
Fold(ValueExpression values,
BinaryOperator<ValueExpression> reducer,
ValueExpression initial) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
ImmutableList<Optional<Value>> |
eval(ParseState parseState,
Encoding encoding) |
int |
hashCode() |
protected abstract ImmutableList<Optional<Value>> |
prepareValues(ImmutableList<Optional<Value>> values) |
protected abstract ValueExpression |
reduce(BinaryOperator<ValueExpression> reducer,
Value head,
Value tail) |
String |
toString() |
public final ValueExpression values
public final BinaryOperator<ValueExpression> reducer
public final ValueExpression initial
public Fold(ValueExpression values, BinaryOperator<ValueExpression> reducer, ValueExpression initial)
public ImmutableList<Optional<Value>> eval(ParseState parseState, Encoding encoding)
eval in interface ValueExpressionprotected abstract ImmutableList<Optional<Value>> prepareValues(ImmutableList<Optional<Value>> values)
protected abstract ValueExpression reduce(BinaryOperator<ValueExpression> reducer, Value head, Value tail)
Copyright © 2017. All rights reserved.