Top Description Constructors Methods
org.terracotta.context.query

public final Class Matchers

extends Object
Class Inheritance
Imports
org.terracotta.context.ContextElement, .TreeNode, java.util.Map

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
type of the object to be matched
T
>
Matcher<T>

Returns:

a compound matcher
allOf
(final Matcher<? super T>...
list of matchers to match
matchers
)

Returns a matcher that matches when against objects which match all of the supplied matchers.

public static <
type of the object to be matched
T
>
Matcher<T>

Returns:

a compound matcher
anyOf
(final Matcher<? super T>...
list of matchers to match
matchers
)

Returns a matcher that matches when against objects which match any of the supplied matchers.

public static Matcher<ContextElement>

Returns:

a ContextElement matcher
attributes
(final Matcher<Map<String, Object>>
a Map (attributes) matcher
matcher
)

Returns a matcher that matches context elements whose ContextElement#attributes() match against the supplied matcher.

public static Matcher<TreeNode>

Returns:

a TreeNode matcher
context
(final Matcher<ContextElement>
ContextElement matcher
matcher
)

Returns a matcher that matches tree nodes whose TreeNode#getContext() match against the supplied matcher.

public static Matcher<Map<String, Object>>

Returns:

a Map<String, Object> matcher
hasAttribute
(final String
attribute name
key
,
final Object
attribute value
value
)

Returns a matcher that matches attribute maps that include the given attribute entry.

public static Matcher<Map<String, Object>>

Returns:

a Map<String, Object> matcher
hasAttribute
(final String
attribute name
key
,
final Matcher<? extends Object>
attribute value matcher
value
)

Returns a matcher that matches attribute maps the include an attribute with the given name, and whose value matches the given matcher.

public static Matcher<ContextElement>

Returns:

a ContextElement matcher
identifier
(final Matcher<Class<?>>
Class<?> matcher
matcher
)

Returns a matcher that matches context elements whose ContextElement#identifier() match against the supplied matcher.

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

public static Matcher<Class<?>>

Returns:

a Class<?> matcher
subclassOf
(final Class<?>
a potential super-type
klazz
)

Returns a matcher that matches classes that are sub-types of the supplied class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Matchersback to summary
private Matchers()

Method Detail

allOfback to summary
public static <T> Matcher<T> allOf(final Matcher<? super T>... matchers)

Returns a matcher that matches when against objects which match all of the supplied matchers.

Parameters
<T>
type of the object to be matched
matchers:Matcher<? super T>[]

list of matchers to match

Returns:Matcher<T>

a compound matcher

Annotations
@SafeVarargs
anyOfback to summary
public static <T> Matcher<T> anyOf(final Matcher<? super T>... matchers)

Returns a matcher that matches when against objects which match any of the supplied matchers.

Parameters
<T>
type of the object to be matched
matchers:Matcher<? super T>[]

list of matchers to match

Returns:Matcher<T>

a compound matcher

Annotations
@SafeVarargs
attributesback to summary
public static Matcher<ContextElement> attributes(final Matcher<Map<String, Object>> matcher)

Returns a matcher that matches context elements whose ContextElement#attributes() match against the supplied matcher.

Parameters
matcher:Matcher<Map<String, Object>>

a Map (attributes) matcher

Returns:Matcher<ContextElement>

a ContextElement matcher

contextback to summary
public static Matcher<TreeNode> context(final Matcher<ContextElement> matcher)

Returns a matcher that matches tree nodes whose TreeNode#getContext() match against the supplied matcher.

Parameters
matcher:Matcher<ContextElement>

ContextElement matcher

Returns:Matcher<TreeNode>

a TreeNode matcher

hasAttributeback to summary
public static Matcher<Map<String, Object>> hasAttribute(final String key, final Object value)

Returns a matcher that matches attribute maps that include the given attribute entry.

Parameters
key:String

attribute name

value:Object

attribute value

Returns:Matcher<Map<String, Object>>

a Map<String, Object> matcher

hasAttributeback to summary
public static Matcher<Map<String, Object>> hasAttribute(final String key, final 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:String

attribute name

value:Matcher<? extends Object>

attribute value matcher

Returns:Matcher<Map<String, Object>>

a Map<String, Object> matcher

identifierback to summary
public static Matcher<ContextElement> identifier(final Matcher<Class<?>> matcher)

Returns a matcher that matches context elements whose ContextElement#identifier() match against the supplied matcher.

Parameters
matcher:Matcher<Class<?>>

Class<?> matcher

Returns:Matcher<ContextElement>

a ContextElement matcher

notback to summary
public static <T> Matcher<T> not(final Matcher<T> matcher)
subclassOfback to summary
public static Matcher<Class<?>> subclassOf(final Class<?> klazz)

Returns a matcher that matches classes that are sub-types of the supplied class.

Parameters
klazz:Class<?>

a potential super-type

Returns:Matcher<Class<?>>

a Class<?> matcher