From 73b7098ddebc45ba6025b54fec08e8bdbe53243e Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Sat, 11 Nov 2023 09:28:33 +0000 Subject: [PATCH] refactor: return equals and hascode from delete query Signed-off-by: Otavio Santana --- .../column/DefaultColumnDeleteQuery.java | 27 ++++++++++++++----- .../document/DefaultDocumentDeleteQuery.java | 20 ++++++++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/jnosql-communication/jnosql-communication-column/src/main/java/org/eclipse/jnosql/communication/column/DefaultColumnDeleteQuery.java b/jnosql-communication/jnosql-communication-column/src/main/java/org/eclipse/jnosql/communication/column/DefaultColumnDeleteQuery.java index 3c14b3fb1..b27d17549 100644 --- a/jnosql-communication/jnosql-communication-column/src/main/java/org/eclipse/jnosql/communication/column/DefaultColumnDeleteQuery.java +++ b/jnosql-communication/jnosql-communication-column/src/main/java/org/eclipse/jnosql/communication/column/DefaultColumnDeleteQuery.java @@ -19,6 +19,7 @@ import java.util.List; +import java.util.Objects; import java.util.Optional; import static java.util.Collections.unmodifiableList; @@ -27,15 +28,10 @@ /** * The default implementation of {@link ColumnDeleteQuery} */ -record DefaultColumnDeleteQuery(String columnFamily, ColumnCondition columnCondition, List columns) +record DefaultColumnDeleteQuery(String name, ColumnCondition columnCondition, List columns) implements ColumnDeleteQuery { - @Override - public String name() { - return columnFamily; - } - @Override public Optional condition() { return ofNullable(columnCondition); @@ -46,4 +42,23 @@ public List columns() { return unmodifiableList(columns); } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ColumnDeleteQuery that)) { + return false; + } + return Objects.equals(name, that.name()) && + Objects.equals(columnCondition, that.condition().orElse(null)) && + Objects.equals(columns, that.columns()); + } + + @Override + public int hashCode() { + return Objects.hash(name, columnCondition, columns); + } + + } diff --git a/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentDeleteQuery.java b/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentDeleteQuery.java index bf5981a4e..d5ec7bf80 100644 --- a/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentDeleteQuery.java +++ b/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentDeleteQuery.java @@ -19,6 +19,7 @@ import java.util.List; +import java.util.Objects; import java.util.Optional; import static java.util.Collections.unmodifiableList; @@ -40,4 +41,23 @@ public Optional condition() { public List documents() { return unmodifiableList(documents); } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof DocumentDeleteQuery that)) { + return false; + } + return Objects.equals(name, that.name()) && + Objects.equals(documentCondition, that.condition().orElse(null)) && + Objects.equals(documents, that.documents()); + } + + @Override + public int hashCode() { + return Objects.hash(name, documentCondition, documents); + } + }