public final class InputGroup<P extends Enum<P> & InputPart> extends Object
InputPart implementing Enum entries that
form a syntactic group.
The group's parts have to be separated by a specifiable separator, so they can be matched individually.
To form an InputGroup, use forPart(Enum) or
forPart(Enum, boolean) to start an InputGroup.InputGroupBuilder.
| Modifier and Type | Class and Description |
|---|---|
static class |
InputGroup.InputGroupBuilder<P extends Enum<P> & InputPart>
A builder for
InputGroups. |
| Modifier and Type | Method and Description |
|---|---|
List<LinkedHashMap<P,String>> |
analyze(String term)
Returns a
List of possibilities on how the given term can be split by
this InputGroup's separator to match this InputGroup's
InputParts. |
static <P extends Enum<P> & InputPart> |
forPart(P inputPart)
Begins a new
InputGroup.InputGroupBuilder. |
static <P extends Enum<P> & InputPart> |
forPart(P inputPart,
boolean isOptional)
Begins a new
InputGroup.InputGroupBuilder. |
boolean |
matches(String term)
Returns whether this
InputGroup matches the given input term. |
public boolean matches(String term)
InputGroup matches the given input term.term - The term to match against; might be null.InputGroup, false
otherwisepublic List<LinkedHashMap<P,String>> analyze(String term)
List of possibilities on how the given term can be split by
this InputGroup's separator to match this InputGroup's
InputParts.
For example, for a street-city matching group with the non-optional
parts...
- STREET("[A-Z]{1}[A-Za-z]*( [A-Z]{1}[A-Za-z]*)*") and
- CITY("[A-Z]{1}[A-Za-z]*( [A-Z]{1}[A-Za-z]*)*")
... that allow multiple words per part and the separator " ", the term
"Diagon Alley London" would cause the following output:
List[
Map[
STREET="Diagon",
CITY="Alley London"
],
Map[
STREET="Diagon Alley",
CITY="London"
]
]
term - The term to analyze; might be nullList of possibilities how this group's parts match the
given term; never null, might be empty if this group does not match
the term at all (in this case, matches(String) would return
false for the same term)public static <P extends Enum<P> & InputPart> InputGroup.InputGroupBuilder<P> forPart(P inputPart)
InputGroup.InputGroupBuilder.P - The InputPart implementing Enum type that defines
the group's parts.inputPart - The part to add; might not be null.InputGroup.InputGroupBuilder; never nullpublic static <P extends Enum<P> & InputPart> InputGroup.InputGroupBuilder<P> forPart(P inputPart, boolean isOptional)
InputGroup.InputGroupBuilder.P - The InputPart implementing Enum type that defines
the group's parts.inputPart - The part to add; might not be null.isOptional - Whether the given part is optional in the group; or put
differently, whether it has to occur in an input term.InputGroup.InputGroupBuilder; never nullCopyright © 2018. All rights reserved.