Package com.ezylang.evalex.config
Class ExpressionConfiguration
- java.lang.Object
-
- com.ezylang.evalex.config.ExpressionConfiguration
-
public class ExpressionConfiguration extends java.lang.ObjectThe expression configuration can be used to configure various aspects of expression parsing and evaluation.
ABuilderis provided to create custom configurations, e.g.:
ExpressionConfiguration config = ExpressionConfiguration.builder().mathContext(MathContext.DECIMAL32).arraysAllowed(false).build();
Additional operators and functions can be added to an existing configuration:
ExpressionConfiguration.defaultConfiguration() .withAdditionalOperators( Map.entry("++", new PrefixPlusPlusOperator()), Map.entry("++", new PostfixPlusPlusOperator())) .withAdditionalFunctions(Map.entry("save", new SaveFunction()), Map.entry("update", new UpdateFunction()));
-
-
Field Summary
Fields Modifier and Type Field Description static intDECIMAL_PLACES_ROUNDING_UNLIMITEDSetting the decimal places to unlimited, will disable intermediate rounding.protected static java.util.List<java.time.format.DateTimeFormatter>DEFAULT_DATE_TIME_FORMATTERSThe default date time formatters used when parsing a date string.static java.math.MathContextDEFAULT_MATH_CONTEXTThe default math context has a precision of 68 andRoundingMode.HALF_EVEN.static java.util.Map<java.lang.String,EvaluationValue>StandardConstantsThe standard set constants for EvalEx.
-
Constructor Summary
Constructors Constructor Description ExpressionConfiguration()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ExpressionConfigurationdefaultConfiguration()Convenience method to create a default configuration.ExpressionConfigurationwithAdditionalFunctions(java.util.Map.Entry<java.lang.String,FunctionIfc>... functions)Adds additional functions to this configuration.ExpressionConfigurationwithAdditionalOperators(java.util.Map.Entry<java.lang.String,OperatorIfc>... operators)Adds additional operators to this configuration.
-
-
-
Field Detail
-
StandardConstants
public static final java.util.Map<java.lang.String,EvaluationValue> StandardConstants
The standard set constants for EvalEx.
-
DECIMAL_PLACES_ROUNDING_UNLIMITED
public static final int DECIMAL_PLACES_ROUNDING_UNLIMITED
Setting the decimal places to unlimited, will disable intermediate rounding.- See Also:
- Constant Field Values
-
DEFAULT_MATH_CONTEXT
public static final java.math.MathContext DEFAULT_MATH_CONTEXT
The default math context has a precision of 68 andRoundingMode.HALF_EVEN.
-
DEFAULT_DATE_TIME_FORMATTERS
protected static final java.util.List<java.time.format.DateTimeFormatter> DEFAULT_DATE_TIME_FORMATTERS
The default date time formatters used when parsing a date string. Each format will be tried and the first matching will be used.DateTimeFormatter.ISO_DATE_TIMEDateTimeFormatter.ISO_DATEDateTimeFormatter.ISO_LOCAL_DATE_TIMEDateTimeFormatter.ISO_LOCAL_DATE
-
-
Method Detail
-
defaultConfiguration
public static ExpressionConfiguration defaultConfiguration()
Convenience method to create a default configuration.- Returns:
- A configuration with default settings.
-
withAdditionalOperators
@SafeVarargs public final ExpressionConfiguration withAdditionalOperators(java.util.Map.Entry<java.lang.String,OperatorIfc>... operators)
Adds additional operators to this configuration.- Parameters:
operators- variable number of arguments with a map entry holding the operator name and implementation.
Example:ExpressionConfiguration.defaultConfiguration() .withAdditionalOperators( Map.entry("++", new PrefixPlusPlusOperator()), Map.entry("++", new PostfixPlusPlusOperator()));- Returns:
- The modified configuration, to allow chaining of methods.
-
withAdditionalFunctions
@SafeVarargs public final ExpressionConfiguration withAdditionalFunctions(java.util.Map.Entry<java.lang.String,FunctionIfc>... functions)
Adds additional functions to this configuration.- Parameters:
functions- variable number of arguments with a map entry holding the functions name and implementation.
Example:ExpressionConfiguration.defaultConfiguration() .withAdditionalFunctions( Map.entry("save", new SaveFunction()), Map.entry("update", new UpdateFunction()));- Returns:
- The modified configuration, to allow chaining of methods.
-
-