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:
parent
11b1112771
commit
3553fb7506
@ -1,24 +1,42 @@
|
|||||||
package com.baeldung.axon.commands;
|
package com.baeldung.axon.commands;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.axonframework.commandhandling.TargetAggregateIdentifier;
|
import org.axonframework.modelling.command.TargetAggregateIdentifier;
|
||||||
|
|
||||||
public class CreateMessageCommand {
|
public class CreateMessageCommand {
|
||||||
|
|
||||||
@TargetAggregateIdentifier
|
@TargetAggregateIdentifier
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
public CreateMessageCommand(String id, String text) {
|
public CreateMessageCommand(String id, String text) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return text;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,18 +1,36 @@
|
|||||||
package com.baeldung.axon.commands;
|
package com.baeldung.axon.commands;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.axonframework.commandhandling.TargetAggregateIdentifier;
|
import org.axonframework.modelling.command.TargetAggregateIdentifier;
|
||||||
|
|
||||||
public class MarkReadMessageCommand {
|
public class MarkReadMessageCommand {
|
||||||
|
|
||||||
@TargetAggregateIdentifier
|
@TargetAggregateIdentifier
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
public MarkReadMessageCommand(String id) {
|
public MarkReadMessageCommand(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,20 +1,39 @@
|
|||||||
package com.baeldung.axon.events;
|
package com.baeldung.axon.events;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class MessageCreatedEvent {
|
public class MessageCreatedEvent {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
||||||
public MessageCreatedEvent(String id, String text) {
|
public MessageCreatedEvent(String id, String text) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return text;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,14 +1,33 @@
|
|||||||
package com.baeldung.axon.events;
|
package com.baeldung.axon.events;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class MessageReadEvent {
|
public class MessageReadEvent {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
public MessageReadEvent(String id) {
|
public MessageReadEvent(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user