Skip to content

Commit

Permalink
Implement Table.equals & hashCode
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Aug 23, 2023
1 parent 0adea34 commit d0f2e52
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.Objects;

public class Table {
@JsonProperty(value = "name", required = true)
Expand All @@ -23,4 +26,30 @@ public Table(
this.name = name;
this.compaction = compaction;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Table table = (Table) o;
return Objects.equals(name, table.name) && Objects.equals(compaction, table.compaction);
}

@Override
public int hashCode() {
return Objects.hash(name, compaction);
}

@Override
public String toString() {
try {
return new ObjectMapper().writeValueAsString(this);
} catch (JsonProcessingException je) {
return String.format("Unable to format table (%s)", je.getMessage());
}
}
}

0 comments on commit d0f2e52

Please sign in to comment.