Skip to content

Commit

Permalink
Remove repeated casts in identities'equals method
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Mar 22, 2016
1 parent e541400 commit 61d87e3
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof DiskTypeId
&& baseEquals((DiskTypeId) obj)
&& Objects.equals(zone, ((DiskTypeId) obj).zone)
&& Objects.equals(diskType, ((DiskTypeId) obj).diskType);
if (obj == this) {
return true;
}
if (!(obj instanceof DiskTypeId)) {
return false;
}
DiskTypeId other = (DiskTypeId) obj;
return baseEquals(other)
&& Objects.equals(zone, other.zone)
&& Objects.equals(diskType, other.diskType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Objects;

/**
* Interface for Google Compute Engine forwarding rule identities.
* Base class for Google Compute Engine forwarding rule identities.
*/
public abstract class ForwardingRuleId extends ResourceId {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof InstanceId
&& baseEquals((InstanceId) obj)
&& Objects.equals(zone, ((InstanceId) obj).zone)
&& Objects.equals(instance, ((InstanceId) obj).instance);
if (obj == this) {
return true;
}
if (!(obj instanceof InstanceId)) {
return false;
}
InstanceId other = (InstanceId) obj;
return baseEquals(other)
&& Objects.equals(zone, other.zone)
&& Objects.equals(instance, other.instance);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof LicenseId
&& baseEquals((LicenseId) obj)
&& Objects.equals(license, ((LicenseId) obj).license);
if (obj == this) {
return true;
}
if (!(obj instanceof LicenseId)) {
return false;
}
LicenseId other = (LicenseId) obj;
return baseEquals(other) && Objects.equals(license, other.license);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,16 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof MachineTypeId
&& baseEquals((MachineTypeId) obj)
&& Objects.equals(zone, ((MachineTypeId) obj).zone)
&& Objects.equals(machineType, ((MachineTypeId) obj).machineType);
if (obj == this) {
return true;
}
if (!(obj instanceof MachineTypeId)) {
return false;
}
MachineTypeId other = (MachineTypeId) obj;
return baseEquals(other)
&& Objects.equals(zone, other.zone)
&& Objects.equals(machineType, other.machineType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof RegionAddressId
&& baseEquals((RegionAddressId) obj)
&& Objects.equals(region, ((RegionAddressId) obj).region);
if (obj == this) {
return true;
}
if (!(obj instanceof RegionAddressId)) {
return false;
}
RegionAddressId other = (RegionAddressId) obj;
return baseEquals(other) && Objects.equals(region, other.region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof RegionForwardingRuleId
&& baseEquals((RegionForwardingRuleId) obj)
&& Objects.equals(region, ((RegionForwardingRuleId) obj).region);
if (obj == this) {
return true;
}
if (!(obj instanceof RegionForwardingRuleId)) {
return false;
}
RegionForwardingRuleId other = (RegionForwardingRuleId) obj;
return baseEquals(other) && Objects.equals(region, other.region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof RegionId
&& baseEquals((RegionId) obj)
&& Objects.equals(region, ((RegionId) obj).region);
if (obj == this) {
return true;
}
if (!(obj instanceof RegionId)) {
return false;
}
RegionId other = (RegionId) obj;
return baseEquals(other) && Objects.equals(region, other.region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof RegionOperationId
&& baseEquals((RegionOperationId) obj)
&& Objects.equals(region, ((RegionOperationId) obj).region);
if (obj == this) {
return true;
}
if (!(obj instanceof RegionOperationId)) {
return false;
}
RegionOperationId other = (RegionOperationId) obj;
return baseEquals(other) && Objects.equals(region, other.region);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof ZoneId
&& baseEquals((ZoneId) obj)
&& Objects.equals(zone, ((ZoneId) obj).zone);
if (obj == this) {
return true;
}
if (!(obj instanceof ZoneId)) {
return false;
}
ZoneId other = (ZoneId) obj;
return baseEquals(other) && Objects.equals(zone, other.zone);
}

@Override
Expand Down

0 comments on commit 61d87e3

Please sign in to comment.