eventuate-client-java/src/main/java/io/eventuate/AggregateRepository.java
/**
   *
   * Create a new Aggregate by processing a command and persisting the events
   * @param cmd the command to process
   * @param saveOptions creation options
   * @return the newly persisted aggregate
   */
Create a new Aggregate by processing a command and persisting the events
@param cmd the command to process
@param saveOptions creation options
@return the newly persisted aggregate
Create a new Aggregate by processing a command and persisting the events @param cmd the command to process @param saveOptions creation options @return the newly persisted aggregate
public CompletableFuture<EntityWithIdAndVersion<T>> save(CT cmd, Optional<SaveOptions> saveOptions) {
    T aggregate;
    try {
      aggregate = clasz.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      throw new RuntimeException(e);
    }
    List<Event> events = aggregate.processCommand(cmd);
    Aggregates.applyEventsToMutableAggregate(aggregate, events);
    return aggregateStore.save(clasz, events, saveOptions).thenApply(entityIdAndVersion -> new EntityWithIdAndVersion<>(entityIdAndVersion, aggregate));
  }
public CompletableFuture < EntityWithIdAndVersion < T > > save ( CT cmd , Optional < SaveOptions > saveOptions ) { T aggregate ; try { aggregate = clasz . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new RuntimeException ( e ) ; } List < Event > events = aggregate . processCommand ( cmd ) ; Aggregates . applyEventsToMutableAggregate ( aggregate , events ) ; return aggregateStore . save ( clasz , events , saveOptions ) . thenApply ( entityIdAndVersion -> new EntityWithIdAndVersion < > ( entityIdAndVersion , aggregate ) ) ; }
Create a new Aggregate by processing a command and persisting the events
 @param cmd the command to process
 @param saveOptions creation options
 @return the newly persisted aggregate
Create a new Aggregate by processing a command and persisting the events @param cmd the command to process @param saveOptions creation options @return the newly persisted aggregate