T
- the output of the classifierpublic class PatternMatchingClassifier<T> extends Object implements Classifier<String,T>
Classifier
that maps from String patterns with wildcards to a set of values
of a given type. An input String is matched with the most specific pattern possible to
the corresponding value in an input map. A default value should be specified with a
pattern key of "*".Constructor and Description |
---|
PatternMatchingClassifier()
Default constructor.
|
PatternMatchingClassifier(Map<String,T> values)
Create a classifier from the provided map.
|
Modifier and Type | Method and Description |
---|---|
T |
classify(String classifiable)
Classify the input by matching it against the patterns provided in
setPatternMap(Map) . |
void |
setPatternMap(Map<String,T> values)
A map from pattern to value
|
public PatternMatchingClassifier()
public PatternMatchingClassifier(Map<String,T> values)
values
- the values to use in the PatternMatcher
public void setPatternMap(Map<String,T> values)
values
- the pattern map to setpublic T classify(String classifiable)
setPatternMap(Map)
. The most specific pattern that matches will be used to
locate a value.classify
in interface Classifier<String,T>
classifiable
- the input object. Can be null.IllegalStateException
- if no matching value is found.Copyright © 2021 SpringSource. All rights reserved.