Skip to content

Commit

Permalink
refactor: update document query
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Nov 11, 2023
1 parent 5dc1545 commit 6050942
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -46,6 +47,28 @@ public List<String> 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));
Expand Down

0 comments on commit 6050942

Please sign in to comment.