public abstract class SourcedEntity<T> extends Entity<Object,T>
Modifier | Constructor and Description |
---|---|
protected |
SourcedEntity()
Construct my default state.
|
protected |
SourcedEntity(List<io.vlingo.symbio.Source<T>> stream,
int currentVersion)
Construct my default state.
|
Modifier and Type | Method and Description |
---|---|
protected void |
apply(List<io.vlingo.symbio.Source<T>> sources)
Apply all of the given
sources to myself, which includes appending
them to my journal and reflecting the representative changes to my state. |
protected void |
apply(List<io.vlingo.symbio.Source<T>> sources,
io.vlingo.symbio.Metadata metadata)
Apply all of the given
sources to myself along with metadata . |
protected void |
apply(io.vlingo.symbio.Source<T> source)
Apply the given
source to myself. |
protected void |
apply(io.vlingo.symbio.Source<T> source,
io.vlingo.symbio.Metadata metadata)
Apply the given
source to myself with metadata . |
protected List<io.vlingo.symbio.Source<T>> |
asList(io.vlingo.symbio.Source<T>... sources)
Answer a
List<Source<T>> from the varargs sources . |
int |
currentVersion()
Answer my
currentVersion , which, if zero, indicates that the
receiver is being initially constructed or reconstituted. |
protected io.vlingo.symbio.Metadata |
metadata()
Answer my
Metadata . |
static <SOURCED extends SourcedEntity<?>,SOURCE extends io.vlingo.symbio.Source<?>> |
registerConsumer(Class<SOURCED> sourcedType,
Class<SOURCE> sourceType,
BiConsumer<SOURCED,SOURCE> consumer)
Register the means to apply
sourceType instances for state transition
of sourcedType by means of a given consumer . |
protected <SNAPSHOT> SNAPSHOT |
snapshot()
Answer a valid
SNAPSHOT state instance if a snapshot should
be taken and persisted along with applied Source<T> instance(s). |
protected abstract String |
streamName()
Answer my stream name.
|
protected String |
streamNameFrom(String separator,
String... streamNameSegments)
Answer a representation of a number of segments as a
composite stream name.
|
String |
type()
Answer my type name.
|
applied, applied, id, nextVersion
public static <SOURCED extends SourcedEntity<?>,SOURCE extends io.vlingo.symbio.Source<?>> void registerConsumer(Class<SOURCED> sourcedType, Class<SOURCE> sourceType, BiConsumer<SOURCED,SOURCE> consumer)
sourceType
instances for state transition
of sourcedType
by means of a given consumer
.SOURCED
- the type <? extends Sourced<?>>
of the sourced entity to apply toSOURCE
- the type <? extends Source<?>>
of the source to be appliedsourcedType
- the concrete Class<SOURCED>
type to which sourceType instances are appliedsourceType
- the concrete Class<SOURCE>
type to applyconsumer
- the BiConsumer<SOURCED, SOURCE>
used to perform the application of sourceTypepublic int currentVersion()
Entity
currentVersion
, which, if zero, indicates that the
receiver is being initially constructed or reconstituted.currentVersion
in class Entity<Object,T>
public String type()
protected final void apply(List<io.vlingo.symbio.Source<T>> sources)
sources
to myself, which includes appending
them to my journal and reflecting the representative changes to my state.sources
- the List<Source<T>>
to applyprotected final void apply(List<io.vlingo.symbio.Source<T>> sources, io.vlingo.symbio.Metadata metadata)
sources
to myself along with metadata
.sources
- the List<Source<T>>
to applymetadata
- the Metadata to apply along with sourceprotected final void apply(io.vlingo.symbio.Source<T> source)
source
to myself.source
- the Source<T>
to applyprotected final void apply(io.vlingo.symbio.Source<T> source, io.vlingo.symbio.Metadata metadata)
source
to myself with metadata
.source
- the Source<T>
to applymetadata
- the Metadata to apply along with sourceprotected List<io.vlingo.symbio.Source<T>> asList(io.vlingo.symbio.Source<T>... sources)
List<Source<T>>
from the varargs sources
.sources
- the varargs Source<T>
of sources to answer as a List<Source<T>>
List<Source<T>>
protected io.vlingo.symbio.Metadata metadata()
Metadata
.
Must override if Metadata
is to be supported.protected <SNAPSHOT> SNAPSHOT snapshot()
SNAPSHOT
state instance if a snapshot should
be taken and persisted along with applied Source<T>
instance(s).
Must override if snapshots are to be supported.SNAPSHOT
- the type of the snapshotSNAPSHOT
protected abstract String streamName()
protected String streamNameFrom(String separator, String... streamNameSegments)
streamName()
would use this method if the its stream name is built from segments.separator
- the String separator the insert between segmentsstreamNameSegments
- the varargs String of one or more segmentsCopyright © 2020. All rights reserved.