Projection

public abstract class Projection<I, M extends EntityState, B extends ValidatingBuilder<M>> extends TransactionalEntity<I, S, B> implements EventPlayer, EventSubscriber, HasVersionColumn<I, S>, HasLifecycleColumns<I, S>

Projection holds a structural representation of data extracted from a stream of events.

The process of projecting the event stream into data we collect is performed by event subscribers for the events of interest. These event handlers are implemented in the classes extending this abstract class.

Event subscribers are invoked by a ProjectionRepository that manages instances of a stream projection class.

Parameters

<I>

the type of the IDs

<M>

the type of the state objects holding projection data

Inheritors

Constructors

Link copied to clipboard
protected void Projection()
Creates a new instance.
protected void Projection(I id)
Creates a new instance.

Inherited properties

Link copied to clipboard
public volatile LifecycleFlags lifecycleFlags
The lifecycle flags of the entity.
Link copied to clipboard
public volatile Version version
The version of the entity.

Functions

Link copied to clipboard
protected final B builder()
Obtains the instance of the state builder.
Link copied to clipboard
Provides error message text for the case of not having an active transaction when a state modification call is made.
Link copied to clipboard
protected ProjectionClass<? extends Object> modelClass()
Obtains the model class.
Link copied to clipboard
public BatchDispatchOutcome play(Iterable<Event> events)
Plays the given events against the underlying entity.
Link copied to clipboard
protected ProjectionClass<? extends Object> thisClass()
Obtains model class for this entity.

Inherited functions

Link copied to clipboard
public void afterInvoke(HandlerMethod<? extends Object, ? extends Object, ? extends Object, ? extends Object> method)
A callback for a handler method invocation end.
Link copied to clipboard
public final Api at(Level logLevel)
Obtains a new fluent logging API at the given level.
Link copied to clipboard
public void beforeInvoke(HandlerMethod<? extends Object, ? extends Object, ? extends Object, ? extends Object> method)
A callback for a handler method invocation start.
Link copied to clipboard
public final boolean changed()
Determines whether the state of this entity or its lifecycle flags have been modified since this entity instance creation.
Link copied to clipboard
protected final List<ConstraintViolation> checkEntityState(S newState)
Verifies the new entity state and returns ConstraintViolations, if any.
Link copied to clipboard
protected void checkNotArchived()
Ensures that the entity is not marked as archived.
Link copied to clipboard
protected void checkNotDeleted()
Ensures that the entity is not marked as deleted.
Link copied to clipboard
protected void clearRecentHistory()
Link copied to clipboard
protected final S defaultState()
Obtains the default state of the entity.
Link copied to clipboard
protected void ensureAccessToState()
Ensures that the callee is allowed to access Entity's state() method.
Link copied to clipboard
public boolean equals(Object o)
Link copied to clipboard
public static EventPlayer forTransactionOf(TransactionalEntity<? extends Object, ? extends Object, ? extends Object> entity)
Creates a transactional EventPlayer for the given entity.
Link copied to clipboard
public boolean getArchived()
Obtains the value of archived flag.
Link copied to clipboard
public boolean getDeleted()
Obtains the value of deleted flag.
Link copied to clipboard
public final LifecycleFlags getLifecycleFlags()
Obtains the current state of the entity lifecycle flags.
Link copied to clipboard
public Version getVersion()
Obtains the version of the entity.
Link copied to clipboard
public int hashCode()
Link copied to clipboard
public I id()
Obtains the identifier of the entity.
Link copied to clipboard
public String idAsString()
Obtains ID of the entity in the string form.
Link copied to clipboard
public boolean isActive()
Verifies if any of the lifecycle attributes is set.
Link copied to clipboard
public final boolean isArchived()
Tests whether the entity is marked as archived.
Link copied to clipboard
public final boolean isDeleted()
Tests whether the entity is marked as deleted.
Link copied to clipboard
public LifecycleFlags lifecycleFlags()
Obtains current lifecycle flags.
Link copied to clipboard
public boolean lifecycleFlagsChanged()
Tells whether lifecycle flags of the entity changed since its initialization.
Link copied to clipboard
public DispatchOutcome play(Event event)
Plays the given event.
Link copied to clipboard
Obtains recent history of events of this entity.
Link copied to clipboard
protected void remember(Iterable<Event> events)
Adds events to the recent history.
Link copied to clipboard
protected final void setArchived(boolean archived)
Sets archived} status flag to the passed value.
Link copied to clipboard
protected final void setDeleted(boolean deleted)
Sets deleted} status flag to the passed value.
Link copied to clipboard
protected final void setInitialState(S initialState, Version version)
Sets an initial state for the entity.
Link copied to clipboard
public final S state()
Obtains the state of the entity.
Link copied to clipboard
public String toString()
Link copied to clipboard
protected Transaction<I, ? extends TransactionalEntity<I, S, B>, S, B> tx()
Obtains the transaction used for modifying the entity.
Link copied to clipboard
public Version version()
Obtains the version of the entity.
Link copied to clipboard
protected int versionNumber()
Obtains the version number of the entity.
Link copied to clipboard
public Timestamp whenModified()
Obtains timestamp of the entity version.