ID - Type of the aggregate root identifier.T - Type of the aggregate.public interface Repository<ID extends AggregateRootId,T extends AggregateRoot<ID>>
| Modifier and Type | Method and Description |
|---|---|
void |
add(T aggregate)
Adds a new aggregate to the repository without any meta data.
|
void |
add(T aggregate,
java.lang.String metaType,
java.lang.Object metaData)
Adds a new aggregate to the repository with some meta data.
|
T |
create()
Factory method to create a new aggregate.
|
void |
delete(ID aggregateId,
int expectedVersion)
Deletes an aggregate from the repository.
|
@NotNull java.lang.Class<T> |
getAggregateClass()
Returns the class of the aggregate in the repository.
|
@NotNull EntityType |
getAggregateType()
Returns a unique name for the aggregate root type.
|
T |
read(ID id)
Reads the latest version of an aggregate.
|
T |
read(ID id,
int version)
Reads a given version of an aggregate.
|
void |
update(T aggregate)
Saves the changes on an aggregate in the repository without any meta data.
|
void |
update(T aggregate,
java.lang.String metaType,
java.lang.Object metaData)
Saves the changes on an aggregate in the repository including some meta data.
|
@NotNull @NotNull java.lang.Class<T> getAggregateClass()
@NotNull @NotNull EntityType getAggregateType()
getAggregateClass() class.@NotNull T create()
update(AggregateRoot, String, Object) method to persist this
new aggregate.@NotNull T read(@NotNull ID id) throws AggregateNotFoundException, AggregateDeletedException
id - Unique aggregate identifier.AggregateNotFoundException - An aggregate with the given identifier was not found.AggregateDeletedException - The aggregate with the given identifier was already deleted.@NotNull T read(@NotNull ID id, int version) throws AggregateNotFoundException, AggregateDeletedException, AggregateVersionNotFoundException
id - Unique aggregate identifier.version - Version to read.AggregateNotFoundException - An aggregate with the given identifier was not found.AggregateDeletedException - The aggregate with the given identifier was already deleted.AggregateVersionNotFoundException - An aggregate with the requested version does not exist.void update(@NotNull
T aggregate,
@Nullable
java.lang.String metaType,
@Nullable
java.lang.Object metaData)
throws AggregateVersionConflictException,
AggregateNotFoundException,
AggregateDeletedException
aggregate - Aggregate to store.metaType - Optional unique name that identifies the type of meta data.metaData - Optional information that is not directly available in the event.AggregateVersionConflictException - The expected version didn't match the actual version.AggregateDeletedException - The aggregate with the given identifier was already deleted.AggregateNotFoundException - An aggregate with the given identifier was not found.void add(@NotNull
T aggregate)
throws AggregateAlreadyExistsException,
AggregateDeletedException
aggregate - Aggregate to add.AggregateAlreadyExistsException - The aggregate with the given version could not be created because it already exists.AggregateDeletedException - The aggregate with the given identifier was already deleted.void add(@NotNull
T aggregate,
@Nullable
java.lang.String metaType,
@Nullable
java.lang.Object metaData)
throws AggregateAlreadyExistsException,
AggregateDeletedException
aggregate - Aggregate to add.metaType - Optional unique name that identifies the type of meta data.metaData - Optional information that is not directly available in the event.AggregateAlreadyExistsException - The aggregate with the given version could not be created because it already exists.AggregateDeletedException - The aggregate with the given identifier was already deleted.void update(@NotNull
T aggregate)
throws AggregateVersionConflictException,
AggregateNotFoundException,
AggregateDeletedException
aggregate - Aggregate to store.AggregateVersionConflictException - The expected version didn't match the actual version.AggregateDeletedException - The aggregate with the given identifier was already deleted.AggregateNotFoundException - An aggregate with the given identifier was not found.void delete(@NotNull
ID aggregateId,
int expectedVersion)
throws AggregateVersionConflictException
aggregateId - Identifier of the aggregate to delete.expectedVersion - Expected (current) version of the aggregate.AggregateVersionConflictException - The expected version didn't match the actual version.Copyright © 2019 fuin.org (Germany). All Rights Reserved.