diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java index 1b49a026ac14..977da0981d2a 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java @@ -386,14 +386,12 @@ public String toString() { return toStringHelper().toString(); } - @Override - public int hashCode() { + protected final int baseHashCode() { return Objects.hash(tableId); } - @Override - public boolean equals(Object obj) { - return obj instanceof BaseTableInfo && Objects.equals(toPb(), ((BaseTableInfo) obj).toPb()); + protected final boolean baseEquals(BaseTableInfo tableInfo) { + return Objects.equals(toPb(), tableInfo.toPb()); } Table toPb() { diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CopyJobInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CopyJobInfo.java index bd346a8e1633..d42c90455e50 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CopyJobInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/CopyJobInfo.java @@ -178,12 +178,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof CopyJobInfo && Objects.equals(toPb(), ((CopyJobInfo) obj).toPb()); + return obj instanceof CopyJobInfo && baseEquals((CopyJobInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), sourceTables, destinationTable, createDisposition, + return Objects.hash(baseHashCode(), sourceTables, destinationTable, createDisposition, writeDisposition); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java index 21ccb3fc1642..80a094425484 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExternalTableInfo.java @@ -107,13 +107,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof ExternalTableInfo - && Objects.equals(toPb(), ((ExternalTableInfo) obj).toPb()); + return obj instanceof ExternalTableInfo && baseEquals((ExternalTableInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), configuration); + return Objects.hash(baseHashCode(), configuration); } @Override diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExtractJobInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExtractJobInfo.java index effdab84f265..67f643ce4e19 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExtractJobInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ExtractJobInfo.java @@ -212,12 +212,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof ExtractJobInfo && Objects.equals(toPb(), ((ExtractJobInfo) obj).toPb()); + return obj instanceof ExtractJobInfo && baseEquals((ExtractJobInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), sourceTable, destinationUris, printHeader, fieldDelimiter, + return Objects.hash(baseHashCode(), sourceTable, destinationUris, printHeader, fieldDelimiter, format, compression); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java index de33c483393d..e623aec26dd2 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/JobInfo.java @@ -264,14 +264,12 @@ public String toString() { return toStringHelper().toString(); } - @Override - public int hashCode() { + protected final int baseHashCode() { return Objects.hash(jobId); } - @Override - public boolean equals(Object obj) { - return obj instanceof JobInfo && Objects.equals(toPb(), ((JobInfo) obj).toPb()); + protected final boolean baseEquals(JobInfo jobInfo) { + return Objects.equals(toPb(), jobInfo.toPb()); } Job toPb() { diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadJobInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadJobInfo.java index 4f8d03cbc6a9..21fe51baa4ae 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadJobInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/LoadJobInfo.java @@ -117,12 +117,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof LoadJobInfo && Objects.equals(toPb(), ((LoadJobInfo) obj).toPb()); + return obj instanceof LoadJobInfo && baseEquals((LoadJobInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), sourceUris, configuration); + return Objects.hash(baseHashCode(), sourceUris, configuration); } @Override diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryJobInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryJobInfo.java index ad76d229bf2d..e2a505ffc4dd 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryJobInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/QueryJobInfo.java @@ -447,12 +447,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof QueryJobInfo && Objects.equals(toPb(), ((QueryJobInfo) obj).toPb()); + return obj instanceof QueryJobInfo && baseEquals((QueryJobInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), allowLargeResults, createDisposition, destinationTable, + return Objects.hash(baseHashCode(), allowLargeResults, createDisposition, destinationTable, defaultDataset, flattenResults, priority, query, tableDefinitions, useQueryCache, userDefinedFunctions, writeDisposition, dryRun); } diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java index 54258abc6ddd..aeb1eadd9771 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/TableInfo.java @@ -215,12 +215,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof TableInfo && Objects.equals(toPb(), ((TableInfo) obj).toPb()); + return obj instanceof TableInfo && baseEquals((TableInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), location, streamingBuffer); + return Objects.hash(baseHashCode(), location, streamingBuffer); } @Override diff --git a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java index 9af9e9d7a08e..2698921bc034 100644 --- a/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java +++ b/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/ViewInfo.java @@ -146,12 +146,12 @@ ToStringHelper toStringHelper() { @Override public boolean equals(Object obj) { - return obj instanceof ViewInfo && Objects.equals(toPb(), ((ViewInfo) obj).toPb()); + return obj instanceof ViewInfo && baseEquals((ViewInfo) obj); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), query, userDefinedFunctions); + return Objects.hash(baseHashCode(), query, userDefinedFunctions); } @Override