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:
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.
EventPattern.Builder| Modifier and Type | Class and Description |
|---|---|
static class |
EventPattern.Builder
Builder is the only way to create an
EventFeed instance. |
static class |
EventPattern.FeedInfo
This class provides the information needed by
EPatternFeed to
open and subscribe
to a notification message feed. |
static class |
EventPattern.PatternType
eBus patterns come in two varieties: ordered and
unordered.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
ALL_EVENTS
The group "__ALL_EVENTS__" contains all matched events in
received order.
|
static Predicate<MatchEvent> |
DEFAULT_CONDITION
Default match event which always returns
true. |
static int |
DEFAULT_MATCH_COUNT
The default minimum and maximum match count is 1.
|
static MatchCondition |
DEFAULT_PREDICATE
Default event match predicate returns
true. |
static BiPredicate<List<ENotificationMessage>,ENotificationMessage> |
DEFAULT_UNTIL
The default until predicate always returns
true. |
protected String |
mPatternName
Pattern name used as the
MatchEvent subject. |
| Modifier and Type | Method and Description |
|---|---|
static EventPattern.Builder |
builder(String pName,
EventPattern.PatternType pType)
Returns a named, ordered or unordered event pattern
builder which has no pre-defined parameters.
|
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.
|
EventPattern.FeedInfo |
feedInfo(String feedName)
Returns
EventPattern.FeedInfo for the given feed name. |
boolean |
isExclusive()
Returns
true if the events matching this pattern
are used in one match only. |
EMessageKey |
messageKey(String feedName)
Returns the message key associated with the given feed
name.
|
Map<String,EventPattern.FeedInfo> |
parameters()
Returns the read-only event pattern parameters map.
|
String |
patternName()
Returns the user-assigned pattern name.
|
EventPattern.PatternType |
patternType()
Returns the pattern type.
|
public static final String ALL_EVENTS
public static final BiPredicate<List<ENotificationMessage>,ENotificationMessage> DEFAULT_UNTIL
true.public static final int DEFAULT_MATCH_COUNT
public static final MatchCondition DEFAULT_PREDICATE
true.public static final Predicate<MatchEvent> DEFAULT_CONDITION
true.
This condition should be used when subscriber wants all
match events returned.protected final String mPatternName
MatchEvent subject.public String patternName()
public EventPattern.PatternType patternType()
public Map<String,EventPattern.FeedInfo> parameters()
public boolean isExclusive()
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.
true if events are used in a single match
only.public EventPattern.FeedInfo feedInfo(String feedName)
EventPattern.FeedInfo for the given feed name.feedName - a known feed name from parameters map.IllegalArgumentException - if parameter is not a known feed name.public EMessageKey messageKey(String feedName)
feedName - feed name in parameters map.IllegalArgumentException - if parameter is not a known feed name.public static EventPattern.Builder builder(String pName, EventPattern.PatternType pType)
EventPattern.Builder.beginParameterMap()/
EventPattern.Builder.endParameterMap() before adding
components to the event pattern.pName - user-assigned pattern name. Used for logging
purposes only.pType - specifies whether the pattern is ordered or
unordered.NullPointerException - if pName or pType is null.IllegalArgumentException - if pName is an empty string.builder(String, PatternType, Map)public static EventPattern.Builder builder(String pName, EventPattern.PatternType pType, Map<String,EventPattern.FeedInfo> 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.
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.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.builder(String, PatternType)Copyright © 2021. All rights reserved.