@JsonDeserialize really necessary for commands?

In the Lagom examples for Java, I’ve seen lots of places where the @JsonDeserialize annotation is used, e.g. for the HelloCommand instances:

public interface HelloCommand extends Jsonable {

  /**
  * A command to switch the greeting message.
  * <p>
  * It has a reply type of {@link Confirmation}, which is sent back to the caller
  * when all the events emitted by this command are successfully persisted.
  */
  @SuppressWarnings("serial")
  @Value
  @JsonDeserialize
  final class UseGreetingMessage implements HelloCommand, CompressedJsonable {
    public final String message;
    public final ActorRef<Confirmation> replyTo;
    
    @JsonCreator
    UseGreetingMessage(String message, ActorRef<Confirmation> replyTo) {
      this.message = Preconditions.checkNotNull(message, "message");
      this.replyTo = replyTo;
    }
  }

It seems to me that the example works fine without the @JsonDeserialize annotation.

Regards,
Bertil

1 Like