com.stuffthathappens.classbus
Class MatcherMaker

java.lang.Object
  extended by com.stuffthathappens.classbus.MatcherMaker

public class MatcherMaker
extends java.lang.Object

Static factory methods for creating Matcher objects. We recommend using static imports for the most concise possible syntax:

 EventService eventService = ...
 eventService.subscribe(exactChannel(myChannel), exactType(String.class), mySubscriber);
 

Author:
Eric M. Burke

Method Summary
static Matcher<java.lang.String> anyChannel()
          Create a matcher that accepts events sent to any channel.
static Matcher<java.lang.String> exactChannel(java.lang.String matchOnChannel)
          Create an exact matcher.
static
<T> Matcher<java.lang.Object>
exactType(java.lang.Class<T> matchOnType)
          Create a matcher that matches when the eventClass is an exact match.
static Matcher<java.lang.String> nullChannel()
          Create the null channel matcher.
static Matcher<java.lang.String> regexChannel(java.lang.String regex)
          Create a matcher that accepts events sent to channels matching the given regular expression.
static
<T> Matcher<java.lang.Object>
subtype(java.lang.Class<T> matchOnType)
          If you pass "Base" as the matchOnType, then events of type "Base" as well as "Derived" will be valid matches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

exactChannel

public static Matcher<java.lang.String> exactChannel(java.lang.String matchOnChannel)
Create an exact matcher.

Parameters:
matchOnChannel - the channel name to match (exactly), or null to only accept events sent to the null channel.
Returns:
a matcher that only accepts events sent to the specified channel.

nullChannel

public static Matcher<java.lang.String> nullChannel()
Create the null channel matcher.

Returns:
a matcher that only accepts events sent to the null channel.

anyChannel

public static Matcher<java.lang.String> anyChannel()
Create a matcher that accepts events sent to any channel.

Returns:
a matcher that accepts events sent to any channel.

regexChannel

public static Matcher<java.lang.String> regexChannel(java.lang.String regex)
Create a matcher that accepts events sent to channels matching the given regular expression.

Parameters:
regex - a regular expression.
Returns:
a matcher that accepts events sent to channels matching the given regex.

exactType

public static <T> Matcher<java.lang.Object> exactType(java.lang.Class<T> matchOnType)
Create a matcher that matches when the eventClass is an exact match.

Parameters:
matchOnType - the type of event.

subtype

public static <T> Matcher<java.lang.Object> subtype(java.lang.Class<T> matchOnType)
If you pass "Base" as the matchOnType, then events of type "Base" as well as "Derived" will be valid matches.

Parameters:
matchOnType - the base class to match on, events matching this type as well as subtypes of this class are considered matches.
Returns:
a matcher that returns true if the event is the same as, or a subtype of matchOnType.