java.lang.Object
org.elasticsearch.xpack.core.ml.utils.NameResolver
Expands an expression into the set of matching names.
It optionally supports aliases to the name set.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNameResolver(Function<String, ResourceNotFoundException> notFoundExceptionSupplier) -
Method Summary
Modifier and TypeMethodDescriptionExpands an expression into the set of matching names.Expands an expression into the set of matching names.keys()Looks up a key and returns the matching names.nameSet()static NameResolvernewUnaliased(Set<String> nameSet, Function<String, ResourceNotFoundException> notFoundExceptionSupplier) Creates aNameResolverthat has no aliases
-
Constructor Details
-
NameResolver
-
-
Method Details
-
expand
Expands an expression into the set of matching names. For example, given a set of names ["foo-1", "foo-2", "bar-1", bar-2"], expressions resolve as follows:- "foo-1" : ["foo-1"]
- "bar-1" : ["bar-1"]
- "foo-*" : ["foo-1", "foo-2"]
- "*-1" : ["bar-1", "foo-1"]
- "*" : ["bar-1", "bar-2", "foo-1", "foo-2"]
- "_all" : ["bar-1", "bar-2", "foo-1", "foo-2"]
- Parameters:
expression- the expression to resolveallowNoMatch- iffalse, an error is thrown when no name matches theexpression. This only applies to wild card expressions, ifexpressionis not a wildcard then setting this true will not suppress the exception- Returns:
- the sorted set of matching names
-
expand
public SortedSet<String> expand(String expression, boolean allowNoMatch, Optional<String> tokenizationDelimiter) Expands an expression into the set of matching names. If a tokenization delimiter is provided, then the expression is first tokenized and then each token is expanded. For example, given a set of names ["foo-1", "foo-2", "bar-1", bar-2"] and comma as the delimiter expressions resolve as follows:- "foo-1" : ["foo-1"]
- "bar-1" : ["bar-1"]
- "foo-1,foo-2" : ["foo-1", "foo-2"]
- "foo-*" : ["foo-1", "foo-2"]
- "*-1" : ["bar-1", "foo-1"]
- "*" : ["bar-1", "bar-2", "foo-1", "foo-2"]
- "_all" : ["bar-1", "bar-2", "foo-1", "foo-2"]
- Parameters:
expression- the expression to resolveallowNoMatch- iffalse, an error is thrown when no name matches theexpression. This only applies to wild card expressions, ifexpressionis not a wildcard then setting this true will not suppress the exceptiontokenizationDelimiter- An optional delimiter to tokenize the expression on- Returns:
- the sorted set of matching names
-
keys
- Returns:
- the set of registered keys
-
nameSet
- Returns:
- the set of all names
-
lookup
Looks up a key and returns the matching names.- Parameters:
key- the key to look up- Returns:
- a list of the matching names or
nullwhen no matching names exist
-
newUnaliased
public static NameResolver newUnaliased(Set<String> nameSet, Function<String, ResourceNotFoundException> notFoundExceptionSupplier) Creates aNameResolverthat has no aliases- Parameters:
nameSet- the set of all namesnotFoundExceptionSupplier- a supplier ofResourceNotFoundExceptionto be used when an expression matches no name- Returns:
- the unaliased
NameResolver
-