Class EventPattern


  • public final class EventPattern
    extends Object

    EventPattern provides the two pieces of information needed to do pattern matching: 1) the notification feeds providing the events used in the match and 2) the pattern itself. Patterns come in two types:

    • Ordered: events must arrive in the event pattern order to effect a match.
    • Unordered: specifies the number of each event type which must be collected to effect a match where the events may arrive in any order.

    Once an event series is received matching the pattern, those events are tested against the pattern condition. Only if that condition is satisfied is a MatchEvent generated and forwarded to the subscriber.

    Event patterns are constructed via EventPattern.Builder. See that class for detailed instructions on building event patterns.

    Author:
    Charles W. Rapp
    See Also:
    EventPattern.Builder
    • Field Detail

      • ALL_EVENTS

        public static final String ALL_EVENTS
        The group "__ALL_EVENTS__" contains all matched events in received order. This means the order may not be chronological according to the event timestamp.
        See Also:
        Constant Field Values
      • DEFAULT_MATCH_COUNT

        public static final int DEFAULT_MATCH_COUNT
        The default minimum and maximum match count is 1.
        See Also:
        Constant Field Values
      • DEFAULT_PREDICATE

        public static final MatchCondition DEFAULT_PREDICATE
        Default event match predicate returns true.
      • DEFAULT_CONDITION

        public static final Predicate<MatchEvent> DEFAULT_CONDITION
        Default match event which always returns true. This condition should be used when subscriber wants all match events returned.
      • mPatternName

        protected final String mPatternName
        Pattern name used as the MatchEvent subject.
    • Method Detail

      • patternName

        public String patternName()
        Returns the user-assigned pattern name.
        Returns:
        pattern name.
      • parameters

        public Map<String,​EventPattern.FeedInfo> parameters()
        Returns the read-only event pattern parameters map.
        Returns:
        event pattern parameters map.
      • isExclusive

        public boolean isExclusive()
        Returns true if the events matching this pattern are used in one match only. This means that if an event could be used in two separate matches of the same pattern, it will be used for only the the first completed match. The second match will be dropped as a result.

        Exclusive is only within a single pattern. Exclusion does not work between two separate pattern instances.

        Returns:
        true if events are used in a single match only.
      • messageKey

        public EMessageKey messageKey​(String feedName)
        Returns the message key associated with the given feed name.
        Parameters:
        feedName - feed name in parameters map.
        Returns:
        message key.
        Throws:
        IllegalArgumentException - if parameter is not a known feed name.
      • builder

        public static EventPattern.Builder builder​(String pName,
                                                   EventPattern.PatternType pType,
                                                   Map<String,​EventPattern.FeedInfo> parameters)
        Returns a named, ordered or unordered event pattern builder using the given parameters. parameters maps a unique name to a notification feed. The map keys are used in the event pattern regular expression to reference a particular notification feed.

        This map may not be null, empty, or contain null values.

        Parameters:
        pName - user-assigned pattern name. Used as the subject for posted match events. purposes only. May not be null or empty.
        pType - specifies whether the pattern is ordered or unordered.
        parameters - event pattern parameters.
        Returns:
        event pattern builder.
        Throws:
        NullPointerException - if pName, pType, or parameters is null.
        IllegalArgumentException - if pName is an empty string or parameters is either empty or contains a null value.
        See Also:
        builder(String, PatternType)