T - the aggregate class, which is a subtype of CommandProcessingAggregateCT - the aggregate's command class, a subtype of command
For example:
public class AccountService {
private final AggregateRepository>Account, AccountCommand> accountRepository;
public AccountService(AggregateRepository>Account, AccountCommand> accountRepository) {
this.accountRepository = accountRepository;
}
public CompletableFuture>EntityWithIdAndVersion>Account>> openAccount(BigDecimal initialBalance) {
return accountRepository.save(new CreateAccountCommand(initialBalance));
}
}
public class AggregateRepository<T extends CommandProcessingAggregate<T,CT>,CT extends Command> extends CommonAggregateRepository<T,CT>
CommandProcessingAggregate,
Commandclasz, interceptor, missingApplyEventMethodStrategy| Constructor and Description |
|---|
AggregateRepository(java.lang.Class<T> clasz,
EventuateAggregateStore aggregateStore)
Constructs a new AggregateRepository for the specified aggregate class and aggregate store
|
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<EntityWithMetadata<T>> |
find(java.lang.String entityId)
Find an aggregate
|
java.util.concurrent.CompletableFuture<EntityWithMetadata<T>> |
find(java.lang.String entityId,
FindOptions findOptions)
Find an aggregate
|
java.util.concurrent.CompletableFuture<EntityWithMetadata<T>> |
find(java.lang.String entityId,
java.util.Optional<FindOptions> findOptions)
Find an aggregate
|
java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> |
save(CT cmd)
Create a new Aggregate by processing a command and persisting the events
|
java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> |
save(CT cmd,
java.util.Optional<SaveOptions> saveOptions)
Create a new Aggregate by processing a command and persisting the events
|
java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> |
update(java.lang.String entityId,
CT cmd)
Update the specified aggregate by processing a command and saving events
|
java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> |
update(java.lang.String entityId,
CT cmd,
java.util.Optional<UpdateOptions> updateOptions)
Update the specified aggregate by processing a command and saving events
|
java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> |
updateWithProvidedCommand(java.lang.String entityId,
java.util.function.Function<T,java.util.Optional<CT>> commandProvider,
java.util.Optional<UpdateOptions> updateOptions)
Update the specified aggregate by processing a command and saving events
|
setInterceptor, setMissingApplyEventMethodStrategy, transformUpdateEventsAndOptionspublic AggregateRepository(java.lang.Class<T> clasz, EventuateAggregateStore aggregateStore)
clasz - the class of the aggregateaggregateStore - the aggregate storepublic java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> save(CT cmd)
cmd - the command to processpublic java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> save(CT cmd, java.util.Optional<SaveOptions> saveOptions)
cmd - the command to processsaveOptions - creation optionspublic java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> update(java.lang.String entityId, CT cmd)
entityId - the id of the aggregate to updatecmd - the command to processpublic java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> update(java.lang.String entityId, CT cmd, java.util.Optional<UpdateOptions> updateOptions)
entityId - the id of the aggregate to updatecmd - the command to processupdateOptions - options for updatingpublic java.util.concurrent.CompletableFuture<EntityWithIdAndVersion<T>> updateWithProvidedCommand(java.lang.String entityId, java.util.function.Function<T,java.util.Optional<CT>> commandProvider, java.util.Optional<UpdateOptions> updateOptions)
entityId - the id of the aggregate to updatecommandProvider - the provider of the command to processupdateOptions - options for updatingpublic java.util.concurrent.CompletableFuture<EntityWithMetadata<T>> find(java.lang.String entityId)
entityId - the id of the aggregate to findpublic java.util.concurrent.CompletableFuture<EntityWithMetadata<T>> find(java.lang.String entityId, FindOptions findOptions)
entityId - the id of the aggregate to findfindOptions - options for findingpublic java.util.concurrent.CompletableFuture<EntityWithMetadata<T>> find(java.lang.String entityId, java.util.Optional<FindOptions> findOptions)
entityId - the id of the aggregate to findfindOptions - options for finding