org.terracotta.context.query
Class Matchers

java.lang.Object
  extended by org.terracotta.context.query.Matchers

public final class Matchers
extends Object

A static library of Matcher implementations that can be used with the QueryBuilder.filter(Matcher) method.


Method Summary
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<Map<String,Object>> matcher)
          Returns a matcher that matches context elements whose ContextElement.attributes() match against the supplied matcher.
static Matcher<TreeNode> context(Matcher<ContextElement> matcher)
          Returns a matcher that matches tree nodes whose TreeNode.getContext() match against the supplied matcher.
static Matcher<Map<String,Object>> hasAttribute(String key, Matcher<? extends 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<Map<String,Object>> hasAttribute(String key, Object value)
          Returns a matcher that matches attribute maps that include the given attribute entry.
static Matcher<ContextElement> identifier(Matcher<Class<?>> matcher)
          Returns a matcher that matches context elements whose ContextElement.identifier() match against the supplied matcher.
static
<T> Matcher<T>
not(Matcher<T> matcher)
           
static Matcher<Class<?>> subclassOf(Class<?> klazz)
          Returns a matcher that matches classes that are sub-types of the supplied class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

context

public static Matcher<TreeNode> context(Matcher<ContextElement> matcher)
Returns a matcher that matches tree nodes whose TreeNode.getContext() match against the supplied matcher.

Parameters:
matcher - ContextElement matcher
Returns:
a TreeNode matcher

attributes

public static Matcher<ContextElement> attributes(Matcher<Map<String,Object>> matcher)
Returns a matcher that matches context elements whose ContextElement.attributes() match against the supplied matcher.

Parameters:
matcher - a Map (attributes) matcher
Returns:
a ContextElement matcher

identifier

public static Matcher<ContextElement> identifier(Matcher<Class<?>> matcher)
Returns a matcher that matches context elements whose ContextElement.identifier() match against the supplied matcher.

Parameters:
matcher - Class<?> matcher
Returns:
a ContextElement matcher

subclassOf

public static Matcher<Class<?>> subclassOf(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<Map<String,Object>> hasAttribute(String key,
                                                       Object value)
Returns a matcher that matches attribute maps that include the given attribute entry.

Parameters:
key - attribute name
value - attribute value
Returns:
a Map<String, Object> matcher

hasAttribute

public static Matcher<Map<String,Object>> hasAttribute(String key,
                                                       Matcher<? extends 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 name
value - attribute value matcher
Returns:
a Map<String, Object> matcher

anyOf

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

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

not

public static <T> Matcher<T> not(Matcher<T> matcher)


Copyright © 2016. All Rights Reserved.