G - The Enum type whose entries identify an
InputGroup.P - The Enum type implementing InputPart for the
group's parts.public final class InputAnalyzer<G extends Enum<G>,P extends Enum<P> & InputPart> extends Object
InputGroup.
To form an InputAnalyzer, use forGroup(Enum, InputGroup) to
start an InputAnalyzer.InputAnalyzerBuilder.
| Modifier and Type | Class and Description |
|---|---|
static class |
InputAnalyzer.InputAnalyzerBuilder<G extends Enum<G>,P extends Enum<P> & InputPart>
Builder for
InputAnalyzers. |
| Modifier and Type | Method and Description |
|---|---|
Map<G,List<LinkedHashMap<P,String>>> |
analyze(String term)
Returns a
Map of groups and their possibilities on how the given term
can be split by the InputGroup's separators to match these
InputGroup's InputParts. |
List<LinkedHashMap<P,String>> |
analyzeForGroup(String term,
G identifier)
Analyzes the given term using a specific
InputGroups of this
InputAnalyzer, identified by the given identifier. |
static <G extends Enum<G>,P extends Enum<P> & InputPart> |
forGroup(G identifier,
InputGroup<P> group)
Begins a new
InputAnalyzer.InputAnalyzerBuilder. |
boolean |
matches(String term)
Matches the given term against all
InputGroups of this
InputAnalyzer. |
boolean |
matchesGroup(String term,
G identifier)
Matches the given term against a specific
InputGroups of this
InputAnalyzer, identified by the given identifier. |
Set<G> |
matching(String term)
Finds the
InputGroups of this InputAnalyzer that match the
given term. |
public boolean matches(String term)
InputGroups of this
InputAnalyzer.term - The term to match against; might be null.InputAnalyzer's InputGroups match
the given term, false otherwisepublic boolean matchesGroup(String term, G identifier)
InputGroups of this
InputAnalyzer, identified by the given identifier.
This effectively equals taking the identified group and calling
InputGroup.matches(String) on it using the given term.
term - The term to match against; might be null.identifier - The identifier that identifies the InputGroup of this
InputAnalyzer to match the term against; might not
be null.InputGroup matches the given term,
false otherwisepublic Set<G> matching(String term)
InputGroups of this InputAnalyzer that match the
given term.term - The term to match against; might be null.Set of identifiers that identify the matching
InputGroups; never null, might be emptypublic Map<G,List<LinkedHashMap<P,String>>> analyze(String term)
Map of groups and their possibilities on how the given term
can be split by the InputGroup's separators to match these
InputGroup's InputParts.
For example, on an InputAnalyzer containing the two
InputGroups and their respective non-optional
InputParts...
- GROUP_STREET_AND_CITY(
PART_STREET("[A-Z]{1}[A-Za-z]*(
[A-Z]{1}[A-Za-z]*)*"),
PART_CITY("[A-Z]{1}[A-Za-z]*(
[A-Z]{1}[A-Za-z]*)*"),
)
- GROUP_FULLNAME(
PART_FORENAME("[A-Z]{1}[A-Za-z]*(
[A-Z]{1}[A-Za-z]*)*"),
PART_LASTNAME("[A-Z]{1}[A-Za-z]*"),
)
... that partially allow multiple words per part and both use the separator "
", the term "Harry James Potter" would cause the following output:
Map[
GROUP_STREET_AND_CITY=List[
Map[
PART_STREET="Harry James",
PART_CITY="Potter"
],
Map[
PART_STREET="Harry",
PART_CITY="James Potter"
]
],
GROUP_FULLNAME=List[
Map[
PART_FORENAME="Harry James",
PART_LASTNAME="Potter"
]
]
]
term - The term to match against; might be null.Map of InputGroup identifiers and those group's
possibilities to match the given input term; never null, might be
empty if no group matches the term at all (in this case,
matches(String) would return false for the same
term)public List<LinkedHashMap<P,String>> analyzeForGroup(String term, G identifier)
InputGroups of this
InputAnalyzer, identified by the given identifier.
This effectively equals taking the identified group and calling
InputGroup.analyze(String) on it using the given term.
term - The term to match against; might be null.identifier - The identifier that identifies the InputGroup of this
InputAnalyzer to match the term against; might not
be null.List of possibilities how the identified group's parts
match the given term; never null, might be empty if the group does
not match the term at all (in this case,
matchesGroup(String, Enum)} would return false
for the same identifier/term combination)public static <G extends Enum<G>,P extends Enum<P> & InputPart> InputAnalyzer.InputAnalyzerBuilder<G,P> forGroup(G identifier, InputGroup<P> group)
InputAnalyzer.InputAnalyzerBuilder.G - The Enum type whose entries identify an
InputGroup.P - The Enum type implementing InputPart for the
group's parts.identifier - The identifier the given group will be identified by the
InputAnalyzer; might not be null.group - The group to add to the InputAnalyzer; might not be
null.InputAnalyzer.InputAnalyzerBuilder; never nullCopyright © 2020. All rights reserved.