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
Modifier and TypeClassDescriptionstatic final class
Builder 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 defineslparen
tokens.Set the prototype for thelparen
token.Set the predicate which definesrparen
tokens.Set the prototype for therparen
token.Set the predicate which definesseparator
tokens.Set the prototype for theseparator
token.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 defineslparen
tokens. If the given predicate returnstrue
for a token, it is treated as lparen.- Parameters:
lparen
- thelparen
token- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if thelparen
isnull
-
lparen
Set the prototype for thelparen
token. A given token is treated aslparen
ifObjects.equals(token, lparen)
returnstrue
.- Parameters:
lparen
- thelparen
prototype- Returns:
this
builder, for method chaining
-
rparen
Set the predicate which definesrparen
tokens. If the given predicate returnstrue
for a token, it is treated as rparen.- Parameters:
rparen
- therparen
token- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if therparen
isnull
-
rparen
Set the prototype for therparen
token. A given token is treated asrparen
ifObjects.equals(token, rparen)
returnstrue
.- Parameters:
rparen
- therparen
prototype- Returns:
this
builder, for method chaining
-
separator
Set the predicate which definesseparator
tokens. If the given predicate returnstrue
for a token, it is treated as separator.- Parameters:
separator
- theseparator
token- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theseparator
isnull
-
separator
Set the prototype for theseparator
token. A given token is treated asseparator
ifObjects.equals(token, separator)
returnstrue
.- Parameters:
separator
- theseparator
prototype- Returns:
this
builder, for method chaining
-
unaryOperators
Set the predicate which defines the unary operator tokens. If the given predicate returnstrue
for a token, it is treated as unary operator.- Parameters:
ops
- thecomma
token- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theops
isnull
-
unaryOperators
Set all unary operator tokens.- Parameters:
ops
- the unary operator tokens- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theops
isnull
-
unaryOperators
Set all unary operator tokens.- Parameters:
ops
- the unary operator tokens- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theops
isnull
-
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:
this
builder, for method chaining- Throws:
NullPointerException
- if theops
isnull
-
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:
this
builder, for method chaining- Throws:
NullPointerException
- if theops
isnull
-
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:
this
builder, for method chaining
-
identifiers
Set the predicate which defines identifier tokens.- Parameters:
identifiers
- the identifier predicate- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theidentifiers
isnull
-
identifiers
Set all identifier tokens.- Parameters:
identifiers
- the identifier tokens- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theidentifiers
isnull
-
identifiers
Set all identifier tokens.- Parameters:
identifiers
- the identifier tokens- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if theidentifiers
isnull
-
functions
Set the predicate which defines function tokens.- Parameters:
functions
- the function predicate- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if thefunctions
isnull
-
functions
Set all functions tokens.- Parameters:
functions
- the function tokens- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if thefunctions
isnull
-
functions
Set all functions tokens.- Parameters:
functions
- the function tokens- Returns:
this
builder, for method chaining- Throws:
NullPointerException
- if thefunctions
isnull
-
build
Create a new formula parser with the defined values.- Returns:
- a new formula parser
-