Package com.codingchili.core.storage
Class QueryParser<T extends Storable>
java.lang.Object
com.codingchili.core.storage.QueryParser<T>
- All Implemented Interfaces:
StringQueryParser<T>
parses a query in string format.
Implementation is pluggable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMap<String,BiConsumer<QueryBuilder<?>,Matcher>>Allows injection of custom defaults into the current instance.static Map<String,BiConsumer<QueryBuilder<?>,Matcher>>defaults()Allow injection of custom operations for all QueryParser instances.static voidMoves the matcher onto the next matching token, throwing an error if there is no next token.static ComparablenextComparable(Matcher matcher)static Comparable[]nextComparableArray(Matcher matcher)static StringMove the parser and then extract the value of the token.Parses a string into a builder.static ComparabletoComparable(String string)Converts the given input string into a comparable depending on its content.static StringExtract the value of the token.
-
Constructor Details
-
QueryParser
- Parameters:
builders- a query builder to use.
-
-
Method Details
-
nextComparable
- Parameters:
matcher- the matcher to get the next comparable. from/- Returns:
- a typed comparable.
-
toComparable
Converts the given input string into a comparable depending on its content.- Parameters:
string- a string that may either represent an integer, double, boolean or a string.- Returns:
- the parsed data type.
-
nextComparableArray
- Parameters:
matcher- the matcher to retrieve comparables from.- Returns:
- an array of comparables, parsed from an input list "one,two,three" and separated by comma.
-
parse
Description copied from interface:StringQueryParserParses a string into a builder.- Specified by:
parsein interfaceStringQueryParser<T extends Storable>- Parameters:
expression- the expression to parse.- Returns:
- the constructed query
-
next
Moves the matcher onto the next matching token, throwing an error if there is no next token.- Parameters:
matcher- the matcher to move.
-
nextValue
Move the parser and then extract the value of the token.- Parameters:
matcher- the matcher to extract the value from.- Returns:
- the unquoted value or the function value. example: remove(id = 5) calls the 'remove' function, this method returns id = 5.
-
value
Extract the value of the token.- Parameters:
matcher- the matcher to extract the value from.- Returns:
- the unquoted value or the function value. example: remove(id = 5) calls the 'remove' function, this method returns id = 5.
-
defaults
Allow injection of custom operations for all QueryParser instances.- Returns:
- a map of defaults operations.
-
customize
Allows injection of custom defaults into the current instance.- Returns:
- a map of custom operations which may be modified.
-