@PluginFactory
public static DynamicThresholdFilter createFilter(
@PluginAttribute("key") final String key,
@PluginElement("Pairs") final KeyValuePair[] pairs,
@PluginAttribute("defaultThreshold") final Level defaultThreshold,
@PluginAttribute("onMatch") final Result onMatch,
@PluginAttribute("onMismatch") final Result onMismatch) {
final Map<String, Level> map = new HashMap<>();
for (final KeyValuePair pair : pairs) {
map.put(pair.getKey(), Level.toLevel(pair.getValue()));
}
final Level level = defaultThreshold == null ? Level.ERROR : defaultThreshold;
return new DynamicThresholdFilter(key, map, level, onMatch, onMismatch);
}