Package net.sf.eBus.feed.historic
Class EAbstractHistoricFeed.Builder<T extends EObject,F extends EAbstractHistoricFeed<T>,B extends EAbstractHistoricFeed.Builder<T,F,?>>
- java.lang.Object
-
- net.sf.eBus.feed.historic.EAbstractHistoricFeed.Builder<T,F,B>
-
- Type Parameters:
T- historic feed owner type.F- subclass feed type.B- subclass builder type.
- Direct Known Subclasses:
EHistoricPublishFeed.Builder,EHistoricSubscribeFeed.Builder
- Enclosing class:
- EAbstractHistoricFeed<T extends EObject>
protected abstract static class EAbstractHistoricFeed.Builder<T extends EObject,F extends EAbstractHistoricFeed<T>,B extends EAbstractHistoricFeed.Builder<T,F,?>> extends Object
Base class forEHistoricPublishFeed.BuilderandEHistoricSubscribeFeed.Buildersubclasses. Provides methods for setting feed name, feed owner, and feed scope. Also defines method for building target feed type and validating common data member settings.
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<F>mFeedClassHistoric feed class being built.protected EMessageKeymKeyNotification message key.protected StringmNameeBus object name.protected TmOwnerThis historic notification hybrid object feed works for this owner.protected EMessageKeymRequestKeyHistoric notification request key.protected EFeed.FeedScopemScopeNotification and reply feed scope.protected EMessageKeymStatusKeyPublishStatusEventmessage key.protected static AtomicIntegersFeedIndexIncremented when a new historic feed is created.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder(T owner, Class<F> feedClass, EMessageKey key)Initializes historic feed abstract elements with the given parameters.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Fbuild()Returns a new historic feed instance created from builder settings.protected abstract FbuildImpl()Returns a new historic feed instance based on builder settings.protected abstract StringgenerateName()Returns default historic feed name.Bname(String name)Sets historic feed name.Bscope(EFeed.FeedScope scope)Sets historic feed scope.protected abstract Bself()Returns subclass builderthisreference.protected net.sf.eBus.util.Validatorvalidate(net.sf.eBus.util.Validator problems)Validates that historic feed owner and scope are set.
-
-
-
Field Detail
-
sFeedIndex
protected static final AtomicInteger sFeedIndex
Incremented when a new historic feed is created.
-
mOwner
protected final T extends EObject mOwner
This historic notification hybrid object feed works for this owner.
-
mFeedClass
protected final Class<F extends EAbstractHistoricFeed<T>> mFeedClass
Historic feed class being built. Used only when throwing a validation exception.
-
mKey
protected final EMessageKey mKey
Notification message key.
-
mStatusKey
protected final EMessageKey mStatusKey
PublishStatusEventmessage key.
-
mRequestKey
protected final EMessageKey mRequestKey
Historic notification request key.
-
mName
protected String mName
eBus object name. If not defined, then set to a default value based on owner name and message key.
-
mScope
protected EFeed.FeedScope mScope
Notification and reply feed scope.
-
-
Constructor Detail
-
Builder
protected Builder(T owner, Class<F> feedClass, EMessageKey key)
Initializes historic feed abstract elements with the given parameters. Sets message store based on the message key.- Parameters:
owner- eBus object owning this historic notification feed.feedClass-key- stores and retrieves messages for this class.
-
-
Method Detail
-
self
protected abstract B self()
Returns subclass builderthisreference.- Returns:
- subclass builder
thisreference.
-
generateName
protected abstract String generateName()
Returns default historic feed name. Used when feed name is not explicitly set.- Returns:
- default historic feed name.
-
buildImpl
protected abstract F buildImpl()
Returns a new historic feed instance based on builder settings.- Returns:
- new historic feed instance.
-
name
public final B name(@Nullable String name)
Sets historic feed name. May benullor an empty string. If so, then name will be set to default value.- Parameters:
name- historic feed name.- Returns:
this Builderinstance.
-
scope
public final B scope(EFeed.FeedScope scope)
Sets historic feed scope. The same scope is used for both notification and request feeds. This means notifications are sent to or received from underlying feeds within this scope.- Parameters:
scope- historic feed scope.- Returns:
this Builderinstance.- Throws:
NullPointerException- ifscopeisnull.
-
build
public final F build()
Returns a new historic feed instance created from builder settings. Validates builder settings prior to building target historic feed instance.If historic feed name is not set, then generates a default feed name.
- Returns:
- new historic feed instance.
- Throws:
net.sf.eBus.util.ValidationException- if this builder's settings are not valid.
-
validate
protected net.sf.eBus.util.Validator validate(net.sf.eBus.util.Validator problems)
Validates that historic feed owner and scope are set. Returnsproblemsparameter to allow forvalidatemethod chaining.- Parameters:
problems- place validation failures into this list.- Returns:
-
-