Module org.elasticsearch.xcore
Class ExpandedIdsMatcher
java.lang.Object
org.elasticsearch.xpack.core.action.util.ExpandedIdsMatcher
Class for tracking the set of Ids returned from some
function a satisfy the required Ids as defined by an
expression that may contain wildcards.
For example, given a set of Ids ["foo-1", "foo-2", "bar-1", bar-2"]:
- The expression foo* would be satisfied by foo-1 and foo-2
- The expression bar-1 would be satisfied by bar-1
- The expression bar-1,car-1 would leave car-1 unmatched
- The expression * would be satisfied by anything or nothing depending on the
value of
allowNoMatchForWildcards
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA simple matcher with one purpose to test whether an id matches a expression that may contain wildcards. -
Constructor Summary
ConstructorsConstructorDescriptionExpandedIdsMatcher(String[] tokens, boolean allowNoMatchForWildcards) Generate the list of required matches from the expressions intokensand initialize.ExpandedIdsMatcher(String expression, boolean allowNoMatchForWildcards) Generate the list of required matches from theexpressionand initialize. -
Method Summary
Modifier and TypeMethodDescriptionvoidfilterMatchedIds(Collection<String> ids) For eachrequiredMatcherscheck there is an element present inidsthat matches.booleanbooleanTest whether an ID matches any of the expressions.booleanWhether ids are based on exact matchers or at least one contains a wildcard.static String[]tokenizeExpression(String expression) Splitexpressioninto tokens separated by a ','
-
Constructor Details
-
ExpandedIdsMatcher
Generate the list of required matches from the expressions intokensand initialize.- Parameters:
tokens- List of expressions that may be wildcards or full IdsallowNoMatchForWildcards- If true then it is not required for wildcard expressions to match an Id meaning they are not returned in the list of required matches
-
ExpandedIdsMatcher
Generate the list of required matches from theexpressionand initialize.- Parameters:
expression- Expression that will be tokenized into a set of wildcards or full IdsallowNoMatchForWildcards- If true then it is not required for wildcard expressions to match an Id meaning they are not returned in the list of required matches
-
-
Method Details
-
tokenizeExpression
Splitexpressioninto tokens separated by a ','- Parameters:
expression- Expression containing zero or more ','s- Returns:
- Array of tokens
-
idMatches
Test whether an ID matches any of the expressions. UnlikefilterMatchedIds(java.util.Collection<java.lang.String>)this does not modify the state of the matcher.- Parameters:
id- ID to test.- Returns:
- Does the ID match one or more of the patterns in the expression?
-
filterMatchedIds
For eachrequiredMatcherscheck there is an element present inidsthat matches. Once a match is made the matcher is removed fromrequiredMatchers. -
hasUnmatchedIds
public boolean hasUnmatchedIds() -
unmatchedIds
-
unmatchedIdsString
-
isOnlyExact
public boolean isOnlyExact()Whether ids are based on exact matchers or at least one contains a wildcard.- Returns:
- true if only exact matches, false if at least one id contains a wildcard
-