diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java index 06de4c5f9f..3b9994fc33 100644 --- a/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/OrderPlacedEvent.java @@ -5,44 +5,36 @@ import java.util.Objects; public class OrderPlacedEvent { private final String orderId; - private final String product; - public OrderPlacedEvent(String orderId, String product) { + public OrderPlacedEvent(String orderId) { this.orderId = orderId; - this.product = product; } public String getOrderId() { return orderId; } - public String getProduct() { - return product; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OrderPlacedEvent that = (OrderPlacedEvent) o; + return Objects.equals(orderId, that.orderId); } @Override public int hashCode() { - return Objects.hash(orderId, product); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - final OrderPlacedEvent other = (OrderPlacedEvent) obj; - return Objects.equals(this.orderId, other.orderId) - && Objects.equals(this.product, other.product); + return Objects.hash(orderId); } @Override public String toString() { return "OrderPlacedEvent{" + "orderId='" + orderId + '\'' + - ", product='" + product + '\'' + '}'; } } \ No newline at end of file diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductAddedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductAddedEvent.java new file mode 100644 index 0000000000..091ef2a570 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductAddedEvent.java @@ -0,0 +1,47 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class ProductAddedEvent { + + private final String orderId; + private final String productId; + + public ProductAddedEvent(String orderId, String productId) { + this.orderId = orderId; + this.productId = productId; + } + + public String getOrderId() { + return orderId; + } + + public String getProductId() { + return productId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProductAddedEvent that = (ProductAddedEvent) o; + return Objects.equals(orderId, that.orderId) && Objects.equals(productId, that.productId); + } + + @Override + public int hashCode() { + return Objects.hash(orderId, productId); + } + + @Override + public String toString() { + return "ProductAddedEvent{" + + "orderId='" + orderId + '\'' + + ", productId='" + productId + '\'' + + '}'; + } +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductCountDecrementedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductCountDecrementedEvent.java new file mode 100644 index 0000000000..4017916791 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductCountDecrementedEvent.java @@ -0,0 +1,47 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class ProductCountDecrementedEvent { + + private final String orderId; + private final String productId; + + public ProductCountDecrementedEvent(String orderId, String productId) { + this.orderId = orderId; + this.productId = productId; + } + + public String getOrderId() { + return orderId; + } + + public String getProductId() { + return productId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProductCountDecrementedEvent that = (ProductCountDecrementedEvent) o; + return Objects.equals(orderId, that.orderId) && Objects.equals(productId, that.productId); + } + + @Override + public int hashCode() { + return Objects.hash(orderId, productId); + } + + @Override + public String toString() { + return "ProductCountDecrementedEvent{" + + "orderId='" + orderId + '\'' + + ", productId='" + productId + '\'' + + '}'; + } +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductCountIncrementedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductCountIncrementedEvent.java new file mode 100644 index 0000000000..2910a9ea6f --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductCountIncrementedEvent.java @@ -0,0 +1,47 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class ProductCountIncrementedEvent { + + private final String orderId; + private final String productId; + + public ProductCountIncrementedEvent(String orderId, String productId) { + this.orderId = orderId; + this.productId = productId; + } + + public String getOrderId() { + return orderId; + } + + public String getProductId() { + return productId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProductCountIncrementedEvent that = (ProductCountIncrementedEvent) o; + return Objects.equals(orderId, that.orderId) && Objects.equals(productId, that.productId); + } + + @Override + public int hashCode() { + return Objects.hash(orderId, productId); + } + + @Override + public String toString() { + return "ProductCountIncrementedEvent{" + + "orderId='" + orderId + '\'' + + ", productId='" + productId + '\'' + + '}'; + } +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductRemovedEvent.java b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductRemovedEvent.java new file mode 100644 index 0000000000..7f89ccd1cc --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/events/ProductRemovedEvent.java @@ -0,0 +1,47 @@ +package com.baeldung.axon.coreapi.events; + +import java.util.Objects; + +public class ProductRemovedEvent { + + private final String orderId; + private final String productId; + + public ProductRemovedEvent(String orderId, String productId) { + this.orderId = orderId; + this.productId = productId; + } + + public String getOrderId() { + return orderId; + } + + public String getProductId() { + return productId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ProductRemovedEvent that = (ProductRemovedEvent) o; + return Objects.equals(orderId, that.orderId) && Objects.equals(productId, that.productId); + } + + @Override + public int hashCode() { + return Objects.hash(orderId, productId); + } + + @Override + public String toString() { + return "ProductRemovedEvent{" + + "orderId='" + orderId + '\'' + + ", productId='" + productId + '\'' + + '}'; + } +}