net.objecthunter.exp4j
Class ExpressionBuilder
- java.lang.Object
-
- net.objecthunter.exp4j.ExpressionBuilder
-
public class ExpressionBuilder extends java.lang.ObjectFactory class forExpressioninstances. This class is the main API entrypoint. Users should create newExpressioninstances using this factory class.
-
-
Constructor Summary
Constructors Constructor and Description ExpressionBuilder(java.lang.String expression)Create a new ExpressionBuilder instance and initialize it with a given expression string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Expressionbuild()Build theExpressioninstance using the custom operators and functions set.ExpressionBuilderfunction(Function function)Add aFunctionimplementation available for use in the expressionExpressionBuilderfunctions(Function... functions)Add multipleFunctionimplementations available for use in the expressionExpressionBuilderfunctions(java.util.List<Function> functions)Add multipleFunctionimplementations available for use in the expressionExpressionBuilderimplicitMultiplication(boolean enabled)ExpressionBuilderoperator(java.util.List<Operator> operators)Add multipleOperatorimplementations which should be available for use in the expressionExpressionBuilderoperator(Operator... operators)Add multipleOperatorimplementations which should be available for use in the expressionExpressionBuilderoperator(Operator operator)Add anOperatorwhich should be available for use in the expressionExpressionBuildervariable(java.lang.String variableName)Declare a variable used in the expressionExpressionBuildervariables(java.util.Set<java.lang.String> variableNames)Declare variable names used in the expressionExpressionBuildervariables(java.lang.String... variableNames)Declare variable names used in the expression
-
-
-
Constructor Detail
-
ExpressionBuilder
public ExpressionBuilder(java.lang.String expression)
Create a new ExpressionBuilder instance and initialize it with a given expression string.- Parameters:
expression- the expression to be parsed
-
-
Method Detail
-
function
public ExpressionBuilder function(Function function)
Add aFunctionimplementation available for use in the expression- Parameters:
function- the customFunctionimplementation that should be available for use in the expression.- Returns:
- the ExpressionBuilder instance
-
functions
public ExpressionBuilder functions(Function... functions)
Add multipleFunctionimplementations available for use in the expression- Parameters:
functions- the customFunctionimplementations- Returns:
- the ExpressionBuilder instance
-
functions
public ExpressionBuilder functions(java.util.List<Function> functions)
Add multipleFunctionimplementations available for use in the expression- Parameters:
functions- AListof customFunctionimplementations- Returns:
- the ExpressionBuilder instance
-
variables
public ExpressionBuilder variables(java.util.Set<java.lang.String> variableNames)
Declare variable names used in the expression- Parameters:
variableNames- the variables used in the expression- Returns:
- the ExpressionBuilder instance
-
variables
public ExpressionBuilder variables(java.lang.String... variableNames)
Declare variable names used in the expression- Parameters:
variableNames- the variables used in the expression- Returns:
- the ExpressionBuilder instance
-
variable
public ExpressionBuilder variable(java.lang.String variableName)
Declare a variable used in the expression- Parameters:
variableName- the variable used in the expression- Returns:
- the ExpressionBuilder instance
-
implicitMultiplication
public ExpressionBuilder implicitMultiplication(boolean enabled)
-
operator
public ExpressionBuilder operator(Operator operator)
Add anOperatorwhich should be available for use in the expression- Parameters:
operator- the customOperatorto add- Returns:
- the ExpressionBuilder instance
-
operator
public ExpressionBuilder operator(Operator... operators)
Add multipleOperatorimplementations which should be available for use in the expression- Parameters:
operators- the set of customOperatorimplementations to add- Returns:
- the ExpressionBuilder instance
-
operator
public ExpressionBuilder operator(java.util.List<Operator> operators)
Add multipleOperatorimplementations which should be available for use in the expression- Parameters:
operators- theListof customOperatorimplementations to add- Returns:
- the ExpressionBuilder instance
-
build
public Expression build()
Build theExpressioninstance using the custom operators and functions set.- Returns:
- an
Expressioninstance which can be used to evaluate the result of the expression
-
-
DMelt 3.0 © DataMelt by jWork.ORG