BAEL-2435 Update commands and events

-Change TargetAggregateIdentifier import statement to the new location
-Add equals/hashcode as best practice for commands and events
-Add description
-Change parent to parent-boot-2 to leverage a spring boot start up
approach
This commit is contained in:
Steven van Beelen 2018-12-18 14:49:30 +01:00
parent 11b1112771
commit 3553fb7506
4 changed files with 90 additions and 16 deletions

View File

@ -1,7 +1,8 @@
package com.baeldung.axon.commands;
import java.util.Objects;
import org.axonframework.commandhandling.TargetAggregateIdentifier;
import org.axonframework.modelling.command.TargetAggregateIdentifier;
public class CreateMessageCommand {
@ -21,4 +22,21 @@ public class CreateMessageCommand {
public String getText() {
return text;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CreateMessageCommand that = (CreateMessageCommand) o;
return Objects.equals(id, that.id) && Objects.equals(text, that.text);
}
@Override
public int hashCode() {
return Objects.hash(id, text);
}
}

View File

@ -1,7 +1,8 @@
package com.baeldung.axon.commands;
import java.util.Objects;
import org.axonframework.commandhandling.TargetAggregateIdentifier;
import org.axonframework.modelling.command.TargetAggregateIdentifier;
public class MarkReadMessageCommand {
@ -15,4 +16,21 @@ public class MarkReadMessageCommand {
public String getId() {
return id;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MarkReadMessageCommand that = (MarkReadMessageCommand) o;
return Objects.equals(id, that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}

View File

@ -1,5 +1,7 @@
package com.baeldung.axon.events;
import java.util.Objects;
public class MessageCreatedEvent {
private final String id;
@ -17,4 +19,21 @@ public class MessageCreatedEvent {
public String getText() {
return text;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MessageCreatedEvent that = (MessageCreatedEvent) o;
return Objects.equals(id, that.id) && Objects.equals(text, that.text);
}
@Override
public int hashCode() {
return Objects.hash(id, text);
}
}

View File

@ -1,5 +1,7 @@
package com.baeldung.axon.events;
import java.util.Objects;
public class MessageReadEvent {
private final String id;
@ -11,4 +13,21 @@ public class MessageReadEvent {
public String getId() {
return id;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MessageReadEvent that = (MessageReadEvent) o;
return Objects.equals(id, that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}