In Java Value entities, pass the state to command handler methods

Currently, in Java, command handler methods as shown in the documentation must explicitly retrieve the state. In JavaScript, the command handler methods include the state in method parameter methods.

Of course, passing the state as a method parameter eliminates a lot of code clutter.


function increase(command, state, ctx) {
  if (command.value < 0) {`Increase requires a positive value. It was [${command.value}].`);
  state.value += command.value;
  return {};


protected Empty increase(CounterApi.IncreaseValue command, CommandContext<CounterDomain.CounterState> ctx) {
    if (command.getValue() < 0) {
        throw"Increase requires a positive value. It was [" + command.getValue() + "].");
    CounterDomain.CounterState state = ctx.getState()
            .orElseGet(() -> CounterDomain.CounterState.newBuilder().build());
    CounterDomain.CounterState newState =
            state.toBuilder().setValue(state.getValue() + command.getValue()).build();
    return Empty.getDefaultInstance();

We will change this, and pass the state as a parameter. Thanks for feedback.