Package io.github.jonestimd.swing.filter
Class BasicFilterParser<T>
- java.lang.Object
-
- io.github.jonestimd.swing.filter.BasicFilterParser<T>
-
- All Implemented Interfaces:
FilterParser<T>
public class BasicFilterParser<T> extends java.lang.Object implements FilterParser<T>
AFilterParserthat generates a compound predicate from the filter text. The filter text may contain terms separated by logical operators. The following logical operators are supported. The operators are listed in the order of precedence (highest first).- grouping: ()
- not: !
- and: &
- or: │
-
-
Constructor Summary
Constructors Constructor Description BasicFilterParser(java.util.function.Function<java.lang.String,java.util.function.Predicate<T>> predicateFactory)Construct a parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>getTerms()Get the individual terms of the parsed predicate.java.util.function.Predicate<T>parse(FilterSource source)Parse the filter text.
-
-
-
Constructor Detail
-
BasicFilterParser
public BasicFilterParser(java.util.function.Function<java.lang.String,java.util.function.Predicate<T>> predicateFactory)
Construct a parser.- Parameters:
predicateFactory- a function for creating a predicate for a single term
-
-
Method Detail
-
parse
public java.util.function.Predicate<T> parse(FilterSource source)
Description copied from interface:FilterParserParse the filter text.- Specified by:
parsein interfaceFilterParser<T>- Returns:
- a predicate matching the parsed filter text
-
getTerms
public java.util.List<java.lang.String> getTerms()
Description copied from interface:FilterParserGet the individual terms of the parsed predicate.- Specified by:
getTermsin interfaceFilterParser<T>
-
-