Skip to content

Commit 2279246

Browse files
committed
BAEL-2435 Switch domain around
Change the domain from 'Messages' to 'Order' as that domain is better suited for an example project like this. First, update the commands and events, adding an extra command/event to flesh out the domain some what
1 parent 557ce65 commit 2279246

10 files changed

Lines changed: 221 additions & 150 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.baeldung.axon.coreapi.commands;
2+
3+
import org.axonframework.modelling.command.TargetAggregateIdentifier;
4+
5+
import java.util.Objects;
6+
7+
public class ConfirmOrderCommand {
8+
9+
@TargetAggregateIdentifier
10+
private final String orderId;
11+
12+
public ConfirmOrderCommand(String orderId) {
13+
this.orderId = orderId;
14+
}
15+
16+
public String getOrderId() {
17+
return orderId;
18+
}
19+
20+
@Override
21+
public int hashCode() {
22+
return Objects.hash(orderId);
23+
}
24+
25+
@Override
26+
public boolean equals(Object obj) {
27+
if (this == obj) {
28+
return true;
29+
}
30+
if (obj == null || getClass() != obj.getClass()) {
31+
return false;
32+
}
33+
final ConfirmOrderCommand other = (ConfirmOrderCommand) obj;
34+
return Objects.equals(this.orderId, other.orderId);
35+
}
36+
}

axon/src/main/java/com/baeldung/axon/coreapi/commands/CreateMessageCommand.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

axon/src/main/java/com/baeldung/axon/coreapi/commands/MarkReadMessageCommand.java

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.baeldung.axon.coreapi.commands;
2+
3+
import java.util.Objects;
4+
5+
import org.axonframework.modelling.command.TargetAggregateIdentifier;
6+
7+
public class PlaceOrderCommand {
8+
9+
@TargetAggregateIdentifier
10+
private final String orderId;
11+
private final String product;
12+
13+
public PlaceOrderCommand(String orderId, String product) {
14+
this.orderId = orderId;
15+
this.product = product;
16+
}
17+
18+
public String getOrderId() {
19+
return orderId;
20+
}
21+
22+
public String getProduct() {
23+
return product;
24+
}
25+
26+
@Override
27+
public int hashCode() {
28+
return Objects.hash(orderId, product);
29+
}
30+
31+
@Override
32+
public boolean equals(Object obj) {
33+
if (this == obj) {
34+
return true;
35+
}
36+
if (obj == null || getClass() != obj.getClass()) {
37+
return false;
38+
}
39+
final PlaceOrderCommand other = (PlaceOrderCommand) obj;
40+
return Objects.equals(this.orderId, other.orderId)
41+
&& Objects.equals(this.product, other.product);
42+
}
43+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.baeldung.axon.coreapi.commands;
2+
3+
import java.util.Objects;
4+
5+
import org.axonframework.modelling.command.TargetAggregateIdentifier;
6+
7+
public class ShipOrderCommand {
8+
9+
@TargetAggregateIdentifier
10+
private final String orderId;
11+
12+
public ShipOrderCommand(String orderId) {
13+
this.orderId = orderId;
14+
}
15+
16+
public String getOrderId() {
17+
return orderId;
18+
}
19+
20+
@Override
21+
public int hashCode() {
22+
return Objects.hash(orderId);
23+
}
24+
25+
@Override
26+
public boolean equals(Object obj) {
27+
if (this == obj) {
28+
return true;
29+
}
30+
if (obj == null || getClass() != obj.getClass()) {
31+
return false;
32+
}
33+
final ShipOrderCommand other = (ShipOrderCommand) obj;
34+
return Objects.equals(this.orderId, other.orderId);
35+
}
36+
}

axon/src/main/java/com/baeldung/axon/coreapi/events/MessageCreatedEvent.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

axon/src/main/java/com/baeldung/axon/coreapi/events/MessageReadEvent.java

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.baeldung.axon.coreapi.events;
2+
3+
import java.util.Objects;
4+
5+
public class OrderConfirmedEvent {
6+
7+
private final String orderId;
8+
9+
public OrderConfirmedEvent(String orderId) {
10+
this.orderId = orderId;
11+
}
12+
13+
public String getOrderId() {
14+
return orderId;
15+
}
16+
17+
@Override
18+
public int hashCode() {
19+
return Objects.hash(orderId);
20+
}
21+
22+
@Override
23+
public boolean equals(Object obj) {
24+
if (this == obj) {
25+
return true;
26+
}
27+
if (obj == null || getClass() != obj.getClass()) {
28+
return false;
29+
}
30+
final OrderConfirmedEvent other = (OrderConfirmedEvent) obj;
31+
return Objects.equals(this.orderId, other.orderId);
32+
}
33+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.baeldung.axon.coreapi.events;
2+
3+
import java.util.Objects;
4+
5+
public class OrderPlacedEvent {
6+
7+
private final String orderId;
8+
private final String product;
9+
10+
public OrderPlacedEvent(String orderId, String product) {
11+
this.orderId = orderId;
12+
this.product = product;
13+
}
14+
15+
public String getOrderId() {
16+
return orderId;
17+
}
18+
19+
public String getProduct() {
20+
return product;
21+
}
22+
23+
@Override
24+
public int hashCode() {
25+
return Objects.hash(orderId, product);
26+
}
27+
28+
@Override
29+
public boolean equals(Object obj) {
30+
if (this == obj) {
31+
return true;
32+
}
33+
if (obj == null || getClass() != obj.getClass()) {
34+
return false;
35+
}
36+
final OrderPlacedEvent other = (OrderPlacedEvent) obj;
37+
return Objects.equals(this.orderId, other.orderId)
38+
&& Objects.equals(this.product, other.product);
39+
}
40+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.baeldung.axon.coreapi.events;
2+
3+
import java.util.Objects;
4+
5+
public class OrderShippedEvent {
6+
7+
private final String orderId;
8+
9+
public OrderShippedEvent(String orderId) {
10+
this.orderId = orderId;
11+
}
12+
13+
public String getOrderId() {
14+
return orderId;
15+
}
16+
17+
@Override
18+
public int hashCode() {
19+
return Objects.hash(orderId);
20+
}
21+
22+
@Override
23+
public boolean equals(Object obj) {
24+
if (this == obj) {
25+
return true;
26+
}
27+
if (obj == null || getClass() != obj.getClass()) {
28+
return false;
29+
}
30+
final OrderShippedEvent other = (OrderShippedEvent) obj;
31+
return Objects.equals(this.orderId, other.orderId);
32+
}
33+
}

0 commit comments

Comments
 (0)