Package org.terracotta.context.query
Class Matchers
- java.lang.Object
-
- org.terracotta.context.query.Matchers
-
public final class Matchers extends java.lang.ObjectA static library ofMatcherimplementations that can be used with theQueryBuilder.filter(Matcher)method.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateMatchers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Matcher<T>allOf(Matcher<? super T>... matchers)Returns a matcher that matches when against objects which match all of the supplied matchers.static <T> Matcher<T>anyOf(Matcher<? super T>... matchers)Returns a matcher that matches when against objects which match any of the supplied matchers.static Matcher<ContextElement>attributes(Matcher<java.util.Map<java.lang.String,java.lang.Object>> matcher)Returns a matcher that matches context elements whoseContextElement.attributes()match against the supplied matcher.static Matcher<TreeNode>context(Matcher<ContextElement> matcher)Returns a matcher that matches tree nodes whoseTreeNode.getContext()match against the supplied matcher.static Matcher<java.util.Map<java.lang.String,java.lang.Object>>hasAttribute(java.lang.String key, java.lang.Object value)Returns a matcher that matches attribute maps that include the given attribute entry.static Matcher<java.util.Map<java.lang.String,java.lang.Object>>hasAttribute(java.lang.String key, Matcher<? extends java.lang.Object> value)Returns a matcher that matches attribute maps the include an attribute with the given name, and whose value matches the given matcher.static Matcher<ContextElement>identifier(Matcher<java.lang.Class<?>> matcher)Returns a matcher that matches context elements whoseContextElement.identifier()match against the supplied matcher.static <T> Matcher<T>not(Matcher<T> matcher)static Matcher<java.lang.Class<?>>subclassOf(java.lang.Class<?> klazz)Returns a matcher that matches classes that are sub-types of the supplied class.
-
-
-
Method Detail
-
context
public static Matcher<TreeNode> context(Matcher<ContextElement> matcher)
Returns a matcher that matches tree nodes whoseTreeNode.getContext()match against the supplied matcher.- Parameters:
matcher-ContextElementmatcher- Returns:
- a
TreeNodematcher
-
attributes
public static Matcher<ContextElement> attributes(Matcher<java.util.Map<java.lang.String,java.lang.Object>> matcher)
Returns a matcher that matches context elements whoseContextElement.attributes()match against the supplied matcher.- Parameters:
matcher- aMap(attributes) matcher- Returns:
- a
ContextElementmatcher
-
identifier
public static Matcher<ContextElement> identifier(Matcher<java.lang.Class<?>> matcher)
Returns a matcher that matches context elements whoseContextElement.identifier()match against the supplied matcher.- Parameters:
matcher-Class<?>matcher- Returns:
- a
ContextElementmatcher
-
subclassOf
public static Matcher<java.lang.Class<?>> subclassOf(java.lang.Class<?> klazz)
Returns a matcher that matches classes that are sub-types of the supplied class.- Parameters:
klazz- a potential super-type- Returns:
- a
Class<?>matcher
-
hasAttribute
public static Matcher<java.util.Map<java.lang.String,java.lang.Object>> hasAttribute(java.lang.String key, java.lang.Object value)
Returns a matcher that matches attribute maps that include the given attribute entry.- Parameters:
key- attribute namevalue- attribute value- Returns:
- a
Map<String, Object>matcher
-
hasAttribute
public static Matcher<java.util.Map<java.lang.String,java.lang.Object>> hasAttribute(java.lang.String key, Matcher<? extends java.lang.Object> value)
Returns a matcher that matches attribute maps the include an attribute with the given name, and whose value matches the given matcher.- Parameters:
key- attribute namevalue- attribute value matcher- Returns:
- a
Map<String, Object>matcher
-
anyOf
@SafeVarargs public static <T> Matcher<T> anyOf(Matcher<? super T>... matchers)
Returns a matcher that matches when against objects which match any of the supplied matchers.- Type Parameters:
T- type of the object to be matched- Parameters:
matchers- list of matchers to match- Returns:
- a compound matcher
-
allOf
@SafeVarargs public static <T> Matcher<T> allOf(Matcher<? super T>... matchers)
Returns a matcher that matches when against objects which match all of the supplied matchers.- Type Parameters:
T- type of the object to be matched- Parameters:
matchers- list of matchers to match- Returns:
- a compound matcher
-
-