java.lang.Object
io.jenetics.ext.internal.util.FormulaParser.Builder<T>
- Type Parameters:
T- the token type
- Enclosing class:
- FormulaParser<T>
Builder for building new
FormulaParser instances.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class for building binary operators with its precedence. -
Method Summary
Modifier and TypeMethodDescriptionbinaryOperators(Consumer<? super FormulaParser.Builder.Bops<T>> ops) Method for defining the binary operators and its precedence.final FormulaParser.Builder<T>binaryOperators(Predicate<? super T>... ops) Set the list of predicates which defines the binary ops.binaryOperators(List<? extends Predicate<? super T>> ops) Set the list of predicates which defines the binary ops.build()Create a new formula parser with the defined values.Set the predicate which defines function tokens.Set all functions tokens.final FormulaParser.Builder<T>Set all functions tokens.identifiers(Predicate<? super T> identifiers) Set the predicate which defines identifier tokens.identifiers(Set<? extends T> identifiers) Set all identifier tokens.final FormulaParser.Builder<T>identifiers(T... identifiers) Set all identifier tokens.Set the predicate which defineslparentokens.Set the prototype for thelparentoken.Set the predicate which definesrparentokens.Set the prototype for therparentoken.Set the predicate which definesseparatortokens.Set the prototype for theseparatortoken.unaryOperators(Predicate<? super T> ops) Set the predicate which defines the unary operator tokens.unaryOperators(Set<? extends T> ops) Set all unary operator tokens.final FormulaParser.Builder<T>unaryOperators(T... ops) Set all unary operator tokens.
-
Method Details
-
lparen
Set the predicate which defineslparentokens. If the given predicate returnstruefor a token, it is treated as lparen.- Parameters:
lparen- thelparentoken- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if thelparenisnull
-
lparen
Set the prototype for thelparentoken. A given token is treated aslparenifObjects.equals(token, lparen)returnstrue.- Parameters:
lparen- thelparenprototype- Returns:
thisbuilder, for method chaining
-
rparen
Set the predicate which definesrparentokens. If the given predicate returnstruefor a token, it is treated as rparen.- Parameters:
rparen- therparentoken- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if therparenisnull
-
rparen
Set the prototype for therparentoken. A given token is treated asrparenifObjects.equals(token, rparen)returnstrue.- Parameters:
rparen- therparenprototype- Returns:
thisbuilder, for method chaining
-
separator
Set the predicate which definesseparatortokens. If the given predicate returnstruefor a token, it is treated as separator.- Parameters:
separator- theseparatortoken- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theseparatorisnull
-
separator
Set the prototype for theseparatortoken. A given token is treated asseparatorifObjects.equals(token, separator)returnstrue.- Parameters:
separator- theseparatorprototype- Returns:
thisbuilder, for method chaining
-
unaryOperators
Set the predicate which defines the unary operator tokens. If the given predicate returnstruefor a token, it is treated as unary operator.- Parameters:
ops- thecommatoken- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theopsisnull
-
unaryOperators
Set all unary operator tokens.- Parameters:
ops- the unary operator tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theopsisnull
-
unaryOperators
Set all unary operator tokens.- Parameters:
ops- the unary operator tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theopsisnull
-
binaryOperators
Set the list of predicates which defines the binary ops. The predicate indexes of the list represent the precedence of the binary ops.ops.get(0)has the lowest precedence andops.get(ops.size() - 1)has the highest precedence- Parameters:
ops- the predicates defining the binary operator tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theopsisnull
-
binaryOperators
Set the list of predicates which defines the binary ops. The predicate indexes of the list represent the precedence of the binary ops.ops.get(0)has the lowest precedence andops.get(ops.size() - 1)has the highest precedence- Parameters:
ops- the predicates defining the binary operator tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theopsisnull
-
binaryOperators
public FormulaParser.Builder<T> binaryOperators(Consumer<? super FormulaParser.Builder.Bops<T>> ops) Method for defining the binary operators and its precedence.- Parameters:
ops- the predicates defining the binary operator tokens- Returns:
thisbuilder, for method chaining
-
identifiers
Set the predicate which defines identifier tokens.- Parameters:
identifiers- the identifier predicate- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theidentifiersisnull
-
identifiers
Set all identifier tokens.- Parameters:
identifiers- the identifier tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theidentifiersisnull
-
identifiers
Set all identifier tokens.- Parameters:
identifiers- the identifier tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if theidentifiersisnull
-
functions
Set the predicate which defines function tokens.- Parameters:
functions- the function predicate- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if thefunctionsisnull
-
functions
Set all functions tokens.- Parameters:
functions- the function tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if thefunctionsisnull
-
functions
Set all functions tokens.- Parameters:
functions- the function tokens- Returns:
thisbuilder, for method chaining- Throws:
NullPointerException- if thefunctionsisnull
-
build
Create a new formula parser with the defined values.- Returns:
- a new formula parser
-