public final class Reducer
extends java.lang.Object
Reducer
provides methods to reduce expressions to a value. Reduction is performed
with the help of the calculator that evaluates specific subexpressions.Constructor and Description |
---|
Reducer() |
Modifier and Type | Method and Description |
---|---|
static Node |
reduce(CalculatorEngine engine,
ReduceOptions options,
Node expression)
Attempts to reduce the specified expression including to a value.
|
static Node |
reduce(CalculatorEngine engine,
ValueProvider valueProvider,
ReduceOptions options,
Node expression)
Attempts to reduce the specified expression including to a value.
|
static Node |
reduce(Node expression)
Attempts to reduce the specified expression including to a value.
|
static Node |
reduce(ReduceOptions options,
Node expression)
Attempts to reduce the specified expression including to a value.
|
static Node |
reduce(ValueProvider valueProvider,
Node expression) |
public static Node reduce(CalculatorEngine engine, ValueProvider valueProvider, ReduceOptions options, Node expression)
The operation may be totally reduced (or, so to speak, reduced to a value), partially reduced or left unchanged. In the last case, the method returns a reference to the current operation (this).
engine
- Calculator engine (if null
, the default engine to be used).valueProvider
- Provider of variable values to be used for expression reduction.options
- Option flags to tune the reduction strategy.expression
- Expression to be reduced.java.lang.IllegalArgumentException
- if any of the parameters is null
.public static Node reduce(ValueProvider valueProvider, Node expression)
public static Node reduce(Node expression)
engine
with ReduceOptions.NEW_INSTANCE
policy.expression
- Expression to be reduced.java.lang.IllegalArgumentException
- if the parameter is null
.reduce(CalculatorEngine, ReduceOptions, Node)
public static Node reduce(ReduceOptions options, Node expression)
engine
.options
- Option flags to tune the reduction strategy.expression
- Expression to be reduced.java.lang.IllegalArgumentException
- if any of the parameters is null
.reduce(CalculatorEngine, ReduceOptions, Node)
public static Node reduce(CalculatorEngine engine, ReduceOptions options, Node expression)
The operation may be totally reduced (or, so to speak, reduced to a value), partially reduced or left unchanged. In the last case, the method returns a reference to the current operation (this).
engine
- Calculator engine (if null
, the default engine to be used).options
- Option flags to tune the reduction strategy.expression
- Expression to be reduced.java.lang.IllegalArgumentException
- if any of the parameters is null
.