Class EventMatcherSugar

java.lang.Object
org.refcodes.observer.EventMatcherSugar

public class EventMatcherSugar extends Object
Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for the EventMatcher elements.
  • Constructor Details

    • EventMatcherSugar

      public EventMatcherSugar()
  • Method Details

    • catchAll

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> catchAll()
      Catches all events, no matching is done.
      Type Parameters:
      E - The type of the event to be matched
      Returns:
      The "catch-all" EventMatcher.
    • catchNone

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> catchNone()
      Catches no event, no matching is done.
      Type Parameters:
      E - The type of the event to be matched
      Returns:
      The "catch-none" EventMatcher.
    • isAssignableFrom

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> isAssignableFrom(Class<?> aEventType)
      Factory method to create an event matcher by event type.
      Type Parameters:
      E - The type of the event to be matched
      Parameters:
      aEventType - The event type to be matched by this matcher.
      Returns:
      An event matcher by event type.
    • publisherIsAssignableFrom

      public static <E extends GenericMetaDataEvent<?, ?>, PT> EventMatcher<E> publisherIsAssignableFrom(Class<? extends PT> aPublisherType)
      Factory method to create an event matcher by event publisher type.
      Type Parameters:
      E - The type of the event to be matched
      PT - The publisher descriptor type
      Parameters:
      aPublisherType - The event publisher type to be matched by this matcher.
      Returns:
      An event matcher by event type.
    • or

      @SafeVarargs public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> or(EventMatcher<E>... aEventMatchers)
      Factory method to create an "OR" matcher for the given matchers.
      Type Parameters:
      E - The event type applied to the matcher
      Parameters:
      aEventMatchers - The matchers to be combined by an "OR".
      Returns:
      An "OR" matcher.
    • and

      @SafeVarargs public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> and(EventMatcher<E>... aEventMatchers)
      Factory method to create an "AND" matcher for the given matchers.
      Type Parameters:
      E - The event type applied to the matcher
      Parameters:
      aEventMatchers - The matchers to be combined by an "AND".
      Returns:
      An "AND" matcher.
    • aliasEqualWith

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> aliasEqualWith(String aAlias)
      Factory method to create an "ALIAS EQUAL WITH" matcher for the given alias compared with the alias stored in the EventMetaData.
      Type Parameters:
      E - The event type applied to the matcher
      Parameters:
      aAlias - The alias to be compared with a GenericMetaDataEvent's EventMetaData's name property.
      Returns:
      An "ALIAS EQUAL WITH" matcher regarding the GenericMetaDataEvent's name property.
    • groupEqualWith

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> groupEqualWith(String aGroup)
      Factory method to create an "GROUP EQUAL WITH" matcher for the given group compared with the group stored in the EventMetaData.
      Type Parameters:
      E - The event type applied to the matcher
      Parameters:
      aGroup - The group to be compared with a GenericMetaDataEvent's EventMetaData's group property.
      Returns:
      An "GROUP EQUAL WITH" matcher regarding the GenericMetaDataEvent's group property.
    • channelEqualWith

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> channelEqualWith(String aChannel)
      Factory method to create an "CHANNEL EQUAL WITH" matcher for the given channel compared with the channel stored in the EventMetaData.
      Type Parameters:
      E - The event type applied to the matcher
      Parameters:
      aChannel - The channel to be compared with a GenericMetaDataEvent's EventMetaData's channel property.
      Returns:
      An "CHANNEL EQUAL WITH" matcher regarding the GenericMetaDataEvent's channel property.
    • universalIdEqualWith

      public static <E extends GenericMetaDataEvent<?, ?>> EventMatcher<E> universalIdEqualWith(String aUid)
      Factory method to create an "UNIVERSAL ID EQUAL WITH" matcher for the given UID compared with the UID stored in the EventMetaData.
      Type Parameters:
      E - The event type applied to the matcher
      Parameters:
      aUid - The UID to be compared with a GenericMetaDataEvent's EventMetaData's UID property.
      Returns:
      An "EQUAL WITH" matcher regarding the GenericMetaDataEvent's UID property.
    • actionEqualWith

      public static <E extends GenericActionMetaDataEvent<A, ?, ?>, A> EventMatcher<E> actionEqualWith(A aAction)
      Factory method to create an "ACTION EQUAL WITH" matcher for the given action compared with the action stored in the EventMetaData.
      Type Parameters:
      E - The event type applied to the matcher.
      A - The type of the action stored in the event. CAUTION: The drawback of not using generic generic type declaration on a class level is no granted type safety, the advantage is the ease of use: Sub-classes can be used out of the box.
      Parameters:
      aAction - The action to be compared with a GenericMetaDataEvent's EventMetaData's action property.
      Returns:
      An "EQUAL WITH" matcher regarding the GenericActionEvent's action property.