Package net.sf.eBus.feed.pattern
Class EPatternFeed.PatternBuilder<F extends EPatternFeed,B extends EPatternFeed.PatternBuilder<F,?>>
- java.lang.Object
-
- net.sf.eBus.client.EFeed.Builder<F,ESubscriber,B>
-
- net.sf.eBus.feed.pattern.EPatternFeed.PatternBuilder<F,B>
-
- Type Parameters:
F- leaf pattern feed class.B- leaf pattern feed builder class.
- Enclosing class:
- EPatternFeed
public abstract static class EPatternFeed.PatternBuilder<F extends EPatternFeed,B extends EPatternFeed.PatternBuilder<F,?>> extends EFeed.Builder<F,ESubscriber,B>
Based class for pattern feed builders. Provides methods for setting the event pattern, status and notify callbacks. If status and/or notify callback methods are not provided, then interface methodsESubscriber.feedStatus(EFeedState, IESubscribeFeed)andESubscriber.notify(ENotificationMessage, IESubscribeFeed)are used.
-
-
Field Summary
Fields Modifier and Type Field Description protected NotifyCallbackmNotifyCallbackNotification message callback.protected EventPatternmPatternEvent pattern.protected FeedStatusCallback<IESubscribeFeed>mStatusCallbackFeed status callback.-
Fields inherited from class net.sf.eBus.client.EFeed.Builder
mEClient, mLocation, mScope, mTarget, mTargetClass
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPatternBuilder(Class<F> tc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeventPattern(EventPattern pattern)Sets event pattern used to match against notification stream.BnotifyCallback(NotifyCallback cb)Puts the notification message callback in place.Bscope(EFeed.FeedScope scope)ThrowsOperationNotSupportedExceptionbecause pattern feed is local only and may be be changed.BstatusCallback(FeedStatusCallback<IESubscribeFeed> cb)Puts the subscribe feed status callback in place.net.sf.eBus.util.Validatorvalidate(net.sf.eBus.util.Validator problems)Validates builder settings.-
Methods inherited from class net.sf.eBus.client.EFeed.Builder
build, buildImpl, isOverridden, self, target
-
-
-
-
Field Detail
-
mPattern
protected EventPattern mPattern
Event pattern.
-
mStatusCallback
protected FeedStatusCallback<IESubscribeFeed> mStatusCallback
Feed status callback. If not explicitly set by client, then defaults toESubscriber.feedStatus(EFeedState, IESubscribeFeed).
-
mNotifyCallback
protected NotifyCallback mNotifyCallback
Notification message callback. If not explicity set by client, then defaults toESubscriber.notify(ENotificationMessage, IESubscribeFeed).
-
-
Method Detail
-
eventPattern
public final B eventPattern(EventPattern pattern)
Sets event pattern used to match against notification stream.- Parameters:
pattern- event pattern.- Returns:
thisbuilder instance.- Throws:
NullPointerException- ifpatternisnull.
-
statusCallback
public final B statusCallback(FeedStatusCallback<IESubscribeFeed> cb)
Puts the subscribe feed status callback in place. Ifcbis notnull, subscribe status updates will be passed tocbrather thanESubscriber.feedStatus(EFeedState, IESubscribeFeed). The reverse is true, ifcbisnull, then updates are posted to theESubscriber.feedStatus(EFeedState, IESubscribeFeed)override.An example using this method is:
statusCallback( (fs, f) → { if (fs == EFeedState.DOWN) { // Clean up in-progress work. } }- Parameters:
cb- subscribe status update callback. May benull.- Returns:
this Builderinstance.
-
notifyCallback
public final B notifyCallback(NotifyCallback cb)
Puts the notification message callback in place. Ifcbis notnull, then notification messages will be passed tocbrather thanESubscriber.notify(ENotificationMessage, IESubscribeFeed). Anull cbmeans that notification messages will be passed to theESubscriber.notify(ENotificationMessage, IESubscribeFeed)override.An example showing how to use this method is:
notifyCallback(this::locationUpdate)- Parameters:
cb- pass notification messages back to target via this callback.- Returns:
this Builderinstance.
-
scope
public final B scope(EFeed.FeedScope scope)
ThrowsOperationNotSupportedExceptionbecause pattern feed is local only and may be be changed.- Overrides:
scopein classEFeed.Builder<F extends EPatternFeed,ESubscriber,B extends EPatternFeed.PatternBuilder<F,?>>- Parameters:
scope- ignored.- Returns:
- does not return.
- Throws:
UnsupportedOperationException- because pattern feed scope may not be changed.
-
validate
public net.sf.eBus.util.Validator validate(net.sf.eBus.util.Validator problems)
Validates builder settings. Missing or invalid settings are placed intoproblemswhich results in aValidationExceptionthrown when pattern feed build is attempted.- Overrides:
validatein classEFeed.Builder<F extends EPatternFeed,ESubscriber,B extends EPatternFeed.PatternBuilder<F,?>>- Parameters:
problems- report invalid settings in this validator.- Returns:
problems.
-
-