Skip to content

Commit

Permalink
refactor: return equals and hascode from delete 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 6050942 commit 73b7098
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import java.util.List;
import java.util.Objects;
import java.util.Optional;

import static java.util.Collections.unmodifiableList;
Expand All @@ -27,15 +28,10 @@
/**
* The default implementation of {@link ColumnDeleteQuery}
*/
record DefaultColumnDeleteQuery(String columnFamily, ColumnCondition columnCondition, List<String> columns)
record DefaultColumnDeleteQuery(String name, ColumnCondition columnCondition, List<String> columns)
implements ColumnDeleteQuery {


@Override
public String name() {
return columnFamily;
}

@Override
public Optional<ColumnCondition> condition() {
return ofNullable(columnCondition);
Expand All @@ -46,4 +42,23 @@ public List<String> 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);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import java.util.List;
import java.util.Objects;
import java.util.Optional;

import static java.util.Collections.unmodifiableList;
Expand All @@ -40,4 +41,23 @@ public Optional<DocumentCondition> condition() {
public List<String> 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);
}

}

0 comments on commit 73b7098

Please sign in to comment.