Package ch.andre601.expressionparser
Class ExpressionParserEngine.Builder<T extends ExpressionParserEngine>
java.lang.Object
ch.andre601.expressionparser.ExpressionParserEngine.Builder<T>
- Type Parameters:
T
- Object implementing theExpressionParserEngine
interface.
- Direct Known Subclasses:
DefaultExpressionParserEngine.DefaultBuilder
- Enclosing interface:
- ExpressionParserEngine
public abstract static class ExpressionParserEngine.Builder<T extends ExpressionParserEngine>
extends Object
Abstract class that can be used to create a new Builder for a
The class offers a
ExpressionParserEngine
.
The class offers a
addDefaults()
method to populate the Lists and Map with default values
(TokenReaders, Operators and ValueReaders).-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionApplies default values for this Builder class to use.addOperator
(Token token, Operator operator) Adds a newToken instance
as key with a newOperator instance
as value to use by theDefaultExpressionParserEngine
.addTokenReader
(TokenReader tokenReader) Adds a newTokenReader instance
to use by theDefaultExpressionParserEngine
.addValueReader
(ValueReader valueReader) Adds a newValueReader instance
to use by theDefaultExpressionParserEngine
.abstract T
build()
Method to build a new instance of what this Builder is using.Deprecated.Method renamed for clarity.Returns a List of currently setTokenReaders
.Returns a List of currently setValueReaders
.
-
Constructor Details
-
Builder
public Builder()Constructor for creating a new Builder.
-
-
Method Details
-
createDefault
Deprecated.Method renamed for clarity. UseaddDefaults()
instead.Applies default values for this Builder class to use. Namely:- TokenReader instances:
PatternTokenReader
withBooleanToken.TRUE
for patterntrue
PatternTokenReader
withBooleanToken.FALSE
for patternfalse
PatternTokenReader
withDefaultTokens.AND
for patternsand
and&&
PatternTokenReader
withDefaultTokens.OR
for patternsor
and||
PatternTokenReader
withDefaultTokens.EQUAL
for patterns=
and==
PatternTokenReader
withDefaultTokens.EQUAL_IGNORE_CASE
for patterns~
and=~
PatternTokenReader
withDefaultTokens.NOT_EQUAL
for pattern!=
PatternTokenReader
withDefaultTokens.NOT_EQUAL_IGNORE_CASE
for pattern!~
PatternTokenReader
withDefaultTokens.STARTS_WITH
for pattern|-
PatternTokenReader
withDefaultTokens.ENDS_WITH
for pattern-|
PatternTokenReader
withDefaultTokens.CONTAINS
for pattern<_
PatternTokenReader
withDefaultTokens.GREATER_THAN
for pattern>
PatternTokenReader
withDefaultTokens.GREATER_OR_EQUAL_THAN
for pattern>=
PatternTokenReader
withDefaultTokens.LESS_THAN
for pattern<
PatternTokenReader
withDefaultTokens.LESS_OR_EQUAL_THAN
for pattern<=
PatternTokenReader
withDefaultTokens.OPENING_PARENTHESIS
for pattern(
PatternTokenReader
withDefaultTokens.CLOSING_PARENTHESIS
for pattern)
PatternTokenReader
withDefaultTokens.NEGATION
for pattern!
PatternTokenReader
withDefaultTokens.CONCAT_STRING
for pattern.
PatternTokenReader
withDefaultTokens.ADD
for pattern+
PatternTokenReader
withDefaultTokens.SUBTRACT
for pattern-
PatternTokenReader
withDefaultTokens.MULTIPLY
for pattern*
PatternTokenReader
withDefaultTokens.DIVIDE
for pattern/
QuotedLiteralTokenReader
with chars"
and'
, and priority -10NumberTokenReader
with priority -50NonQuotedLiteralTokenReader
with priority -100
- Operators:
ListOperator
with priority 100 andExpressionTemplates.and(Collection)
forDefaultTokens.AND
ListOperator
with priority 50 andExpressionTemplates.or(Collection)
forDefaultTokens.OR
Operator
with priority 25 andExpressionTemplates.equal(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.EQUAL
Operator
with priority 25 andExpressionTemplates.equalIgnoreCase(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.EQUAL_IGNORE_CASE
Operator
with priority 25 andExpressionTemplates.notEqual(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.NOT_EQUAL
Operator
with priority 25 andExpressionTemplates.notEqualIgnoreCase(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.NOT_EQUAL_IGNORE_CASE
Operator
with priority 25 andExpressionTemplates.startsWith(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.STARTS_WITH
Operator
with priority 25 andExpressionTemplates.endsWith(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.ENDS_WITH
Operator
with priority 25 andExpressionTemplates.contains(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.CONTAINS
Operator
with priority 25 andExpressionTemplates.greater(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.GREATER_THAN
Operator
with priority 25 andExpressionTemplates.greaterOrEqual(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.GREATER_OR_EQUAL_THAN
Operator
with priority 25 andExpressionTemplates.less(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.LESS_THAN
Operator
with priority 25 andExpressionTemplates.lessOrEqual(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.LESS_OR_EQUAL_THAN
ListOperator
with priority 10 andExpressionTemplates.concat(Collection)
forDefaultTokens.CONCAT_STRING
ListOperator
with priority 4 andExpressionTemplates.sum(Collection)
forDefaultTokens.ADD
Operator
with priority 3 andExpressionTemplates.sub(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.SUBTRACT
ListOperator
with priority 2 andExpressionTemplates.product(Collection)
forDefaultTokens.MULTIPLY
Operator
with priority 1 andExpressionTemplates.div(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.DIVIDE
- ValueReaders:
- Returns:
- This Builder instance with default values applied. Useful for chaining.
- TokenReader instances:
-
addDefaults
Applies default values for this Builder class to use. Namely:- TokenReader instances:
PatternTokenReader
withBooleanToken.TRUE
for patterntrue
PatternTokenReader
withBooleanToken.FALSE
for patternfalse
PatternTokenReader
withDefaultTokens.AND
for patternsand
and&&
PatternTokenReader
withDefaultTokens.OR
for patternsor
and||
PatternTokenReader
withDefaultTokens.EQUAL
for patterns=
and==
PatternTokenReader
withDefaultTokens.EQUAL_IGNORE_CASE
for patterns~
and=~
PatternTokenReader
withDefaultTokens.NOT_EQUAL
for pattern!=
PatternTokenReader
withDefaultTokens.NOT_EQUAL_IGNORE_CASE
for pattern!~
PatternTokenReader
withDefaultTokens.STARTS_WITH
for pattern|-
PatternTokenReader
withDefaultTokens.ENDS_WITH
for pattern-|
PatternTokenReader
withDefaultTokens.CONTAINS
for pattern<_
PatternTokenReader
withDefaultTokens.GREATER_THAN
for pattern>
PatternTokenReader
withDefaultTokens.GREATER_OR_EQUAL_THAN
for pattern>=
PatternTokenReader
withDefaultTokens.LESS_THAN
for pattern<
PatternTokenReader
withDefaultTokens.LESS_OR_EQUAL_THAN
for pattern<=
PatternTokenReader
withDefaultTokens.OPENING_PARENTHESIS
for pattern(
PatternTokenReader
withDefaultTokens.CLOSING_PARENTHESIS
for pattern)
PatternTokenReader
withDefaultTokens.NEGATION
for pattern!
PatternTokenReader
withDefaultTokens.CONCAT_STRING
for pattern.
PatternTokenReader
withDefaultTokens.ADD
for pattern+
PatternTokenReader
withDefaultTokens.SUBTRACT
for pattern-
PatternTokenReader
withDefaultTokens.MULTIPLY
for pattern*
PatternTokenReader
withDefaultTokens.DIVIDE
for pattern/
QuotedLiteralTokenReader
with chars"
and'
, and priority -10NumberTokenReader
with priority -50NonQuotedLiteralTokenReader
with priority -100
- Operators:
ListOperator
with priority 100 andExpressionTemplates.and(Collection)
forDefaultTokens.AND
ListOperator
with priority 50 andExpressionTemplates.or(Collection)
forDefaultTokens.OR
Operator
with priority 25 andExpressionTemplates.equal(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.EQUAL
Operator
with priority 25 andExpressionTemplates.equalIgnoreCase(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.EQUAL_IGNORE_CASE
Operator
with priority 25 andExpressionTemplates.notEqual(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.NOT_EQUAL
Operator
with priority 25 andExpressionTemplates.notEqualIgnoreCase(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.NOT_EQUAL_IGNORE_CASE
Operator
with priority 25 andExpressionTemplates.startsWith(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.STARTS_WITH
Operator
with priority 25 andExpressionTemplates.endsWith(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.ENDS_WITH
Operator
with priority 25 andExpressionTemplates.contains(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.CONTAINS
Operator
with priority 25 andExpressionTemplates.greater(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.GREATER_THAN
Operator
with priority 25 andExpressionTemplates.greaterOrEqual(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.GREATER_OR_EQUAL_THAN
Operator
with priority 25 andExpressionTemplates.less(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.LESS_THAN
Operator
with priority 25 andExpressionTemplates.lessOrEqual(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.LESS_OR_EQUAL_THAN
ListOperator
with priority 10 andExpressionTemplates.concat(Collection)
forDefaultTokens.CONCAT_STRING
ListOperator
with priority 4 andExpressionTemplates.sum(Collection)
forDefaultTokens.ADD
Operator
with priority 3 andExpressionTemplates.sub(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.SUBTRACT
ListOperator
with priority 2 andExpressionTemplates.product(Collection)
forDefaultTokens.MULTIPLY
Operator
with priority 1 andExpressionTemplates.div(ExpressionTemplate, ExpressionTemplate)
forDefaultTokens.DIVIDE
- ValueReaders:
- Returns:
- This Builder instance with default values applied. Useful for chaining.
- TokenReader instances:
-
getTokenReaders
Returns a List of currently setTokenReaders
.- Returns:
- Possibly-empty List of TokenReaders.
-
getOperators
- Returns:
- Possibly-empty Map of Tokens and Operators.
-
getValueReaders
Returns a List of currently setValueReaders
.- Returns:
- Possibly-empty List of ValueReaders.
-
addTokenReader
Adds a newTokenReader instance
to use by theDefaultExpressionParserEngine
.- Parameters:
tokenReader
- The TokenReader instance to add.- Returns:
- This builder instance after adding the TokenReader. Useful for chaining.
-
addOperator
Adds a newToken instance
as key with a newOperator instance
as value to use by theDefaultExpressionParserEngine
.- Parameters:
token
- The Token instance to add as key.operator
- The Operator instance to use as value.- Returns:
- This builder instance after adding the Token and Operator. Useful for chaining.
-
addValueReader
Adds a newValueReader instance
to use by theDefaultExpressionParserEngine
.- Parameters:
valueReader
- The ValueReader instance to add.- Returns:
- This builder instance after adding the ValueReader. Useful for chaining.
-
build
Method to build a new instance of what this Builder is using.- Returns:
- New instance of T.
-