Skip to content

Commit

Permalink
Merge pull request #565 from mziccard/bigquery-table-hash
Browse files Browse the repository at this point in the history
Add equals and hashCode to BaseTableInfo subclasses
  • Loading branch information
ajkannan committed Jan 21, 2016
2 parents 2e8363f + 3521bf5 commit 483b4d8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.google.api.services.bigquery.model.Table;
import com.google.common.base.MoreObjects.ToStringHelper;

import java.util.Objects;

/**
* Google BigQuery External Table information. BigQuery's external tables are tables whose data
* reside outside of BigQuery but can be queried as normal BigQuery tables. External tables are
Expand Down Expand Up @@ -103,6 +105,17 @@ ToStringHelper toStringHelper() {
return super.toStringHelper().add("configuration", configuration);
}

@Override
public boolean equals(Object obj) {
return obj instanceof ExternalTableInfo
&& Objects.equals(toPb(), ((ExternalTableInfo) obj).toPb());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), configuration);
}

@Override
Table toPb() {
Table tablePb = super.toPb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ ToStringHelper toStringHelper() {
.add("streamingBuffer", streamingBuffer);
}

@Override
public boolean equals(Object obj) {
return obj instanceof TableInfo && Objects.equals(toPb(), ((TableInfo) obj).toPb());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), location, streamingBuffer);
}

@Override
Table toPb() {
Table tablePb = super.toPb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.common.collect.Lists;

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

/**
* Google BigQuery View Table information. BigQuery's views are logical views, not materialized
Expand Down Expand Up @@ -143,6 +144,16 @@ ToStringHelper toStringHelper() {
.add("userDefinedFunctions", userDefinedFunctions);
}

@Override
public boolean equals(Object obj) {
return obj instanceof ViewInfo && Objects.equals(toPb(), ((ViewInfo) obj).toPb());
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), query, userDefinedFunctions);
}

@Override
Table toPb() {
Table tablePb = super.toPb();
Expand Down

0 comments on commit 483b4d8

Please sign in to comment.