use of io.spine.server.command.Assign in project core-java by SpineEventEngine.
the class TaskAggregate method handle.
/**
* A command handler that returns a pair with an optional second element.
*
* <p>{@link AggTaskAssigned} is present when the command contains an
* {@linkplain AggCreateTask#getAssignee() assignee}.
*/
@Assign
Pair<AggTaskCreated, Optional<AggTaskAssigned>> handle(AggCreateTask command) {
final AggTaskId id = command.getTaskId();
final AggTaskCreated createdEvent = taskCreated(id);
final UserId assignee = command.getAssignee();
final AggTaskAssigned assignedEvent = taskAssignedOrNull(id, assignee);
return Pair.withNullable(createdEvent, assignedEvent);
}
use of io.spine.server.command.Assign in project core-java by SpineEventEngine.
the class TestAggregate method handle.
@Assign
AggTaskAdded handle(AggAddTask cmd, CommandContext ctx) {
isAddTaskCommandHandled = true;
final AggTaskAdded event = taskAdded(cmd.getProjectId());
return event.toBuilder().setTask(cmd.getTask()).build();
}
Aggregations