diff --git a/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentQuery.java b/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentQuery.java index 561f35c64..0aafdebf3 100644 --- a/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentQuery.java +++ b/jnosql-communication/jnosql-communication-document/src/main/java/org/eclipse/jnosql/communication/document/DefaultDocumentQuery.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.List; +import java.util.Objects; import java.util.Optional; import static java.util.Collections.unmodifiableList; @@ -46,6 +47,28 @@ public List documents() { return unmodifiableList(documents); } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof DocumentQuery that)) { + return false; + } + return limit == that.limit() && + skip == that.skip() && + Objects.equals(name, that.name()) && + Objects.equals(documentCondition, that.condition().orElse(null)) && + Objects.equals(sorts, that.sorts()) && + Objects.equals(documents, that.documents()); + } + + @Override + public int hashCode() { + return Objects.hash(limit, skip, name, documentCondition, sorts, documents); + } + + static DocumentQuery countBy(DocumentQuery query) { return new DefaultDocumentQuery(0, 0, query.name(), query.documents(), Collections.emptyList(), query.condition().orElse(null));