Skip to content

Commit

Permalink
Update Compute equals methods to support mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Apr 29, 2016
1 parent ae0a6d2 commit f0ae430
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,14 @@ public Builder toBuilder() {

@Override
public final boolean equals(Object obj) {
return obj instanceof Address
&& Objects.equals(toPb(), ((Address) obj).toPb())
&& Objects.equals(options, ((Address) obj).options);
if (obj == this) {
return true;
}
if (obj == null || !obj.getClass().equals(Address.class)) {
return false;
}
Address other = (Address) obj;
return Objects.equals(toPb(), other.toPb()) && Objects.equals(options, other.options);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj != null
return obj == this
|| obj != null
&& obj.getClass().equals(AddressInfo.class)
&& Objects.equals(toPb(), ((AddressInfo) obj).toPb());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof DeprecationStatus
return obj == this
|| obj instanceof DeprecationStatus
&& Objects.equals(toPb(), ((DeprecationStatus) obj).toPb());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ public Builder toBuilder() {

@Override
public final boolean equals(Object obj) {
return obj instanceof Disk
&& Objects.equals(toPb(), ((Disk) obj).toPb())
&& Objects.equals(options, ((Disk) obj).options);
if (obj == this) {
return true;
}
if (obj == null || !obj.getClass().equals(Disk.class)) {
return false;
}
Disk other = (Disk) obj;
return Objects.equals(toPb(), other.toPb()) && Objects.equals(options, other.options);
}

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

@Override
public final boolean equals(Object obj) {
return obj instanceof DiskImageConfiguration && baseEquals((DiskImageConfiguration) obj);
return obj == this
|| obj != null
&& obj.getClass().equals(DiskImageConfiguration.class)
&& baseEquals((DiskImageConfiguration) obj);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj != null
return obj == this
|| obj != null
&& obj.getClass().equals(DiskInfo.class)
&& Objects.equals(toPb(), ((DiskInfo) obj).toPb());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ public final int hashCode() {

@Override
public final boolean equals(Object obj) {
return obj instanceof DiskType && Objects.equals(toPb(), ((DiskType) obj).toPb());
return obj == this
|| obj != null
&& obj.getClass().equals(DiskType.class)
&& Objects.equals(toPb(), ((DiskType) obj).toPb());
}

com.google.api.services.compute.model.DiskType toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof GlobalAddressId && baseEquals((GlobalAddressId) obj);
return obj == this || obj instanceof GlobalAddressId && baseEquals((GlobalAddressId) obj);
}

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

@Override
public boolean equals(Object obj) {
return obj instanceof GlobalForwardingRuleId && baseEquals((GlobalForwardingRuleId) obj);
return obj == this
|| obj instanceof GlobalForwardingRuleId
&& baseEquals((GlobalForwardingRuleId) obj);
}

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

@Override
public boolean equals(Object obj) {
return obj instanceof GlobalOperationId && baseEquals((GlobalOperationId) obj);
return obj == this || obj instanceof GlobalOperationId && baseEquals((GlobalOperationId) obj);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,14 @@ public Builder toBuilder() {

@Override
public final boolean equals(Object obj) {
return obj instanceof Image
&& Objects.equals(toPb(), ((Image) obj).toPb())
&& Objects.equals(options, ((Image) obj).options);
if (obj == this) {
return true;
}
if (obj == null || !obj.getClass().equals(Image.class)) {
return false;
}
Image other = (Image) obj;
return Objects.equals(toPb(), other.toPb()) && Objects.equals(options, other.options);
}

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

@Override
public final boolean equals(Object obj) {
return obj instanceof ImageDiskConfiguration && baseEquals((ImageDiskConfiguration) obj);
return obj == this
|| obj != null
&& obj.getClass().equals(ImageDiskConfiguration.class)
&& baseEquals((ImageDiskConfiguration) obj);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj != null
return obj == this
|| obj != null
&& obj.getClass().equals(ImageInfo.class)
&& Objects.equals(toPb(), ((ImageInfo) obj).toPb());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,9 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj instanceof InstanceInfo
return obj == this
|| obj != null
&& obj.getClass().equals(InstanceInfo.class)
&& Objects.equals(toPb(), ((InstanceInfo) obj).toPb());
}

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

@Override
public final boolean equals(Object obj) {
return obj instanceof License && Objects.equals(toPb(), ((License) obj).toPb());
return obj == this
|| obj != null
&& obj.getClass().equals(License.class)
&& Objects.equals(toPb(), ((License) obj).toPb());
}

com.google.api.services.compute.model.License toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ public final int hashCode() {

@Override
public final boolean equals(Object obj) {
return obj instanceof MachineType && Objects.equals(toPb(), ((MachineType) obj).toPb());
return obj == this
|| obj != null
&& obj.getClass().equals(MachineType.class)
&& Objects.equals(toPb(), ((MachineType) obj).toPb());
}

com.google.api.services.compute.model.MachineType toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,14 @@ public final int hashCode() {

@Override
public final boolean equals(Object obj) {
return obj instanceof Operation
&& Objects.equals(toPb(), ((Operation) obj).toPb())
&& Objects.equals(options, ((Operation) obj).options);
if (obj == this) {
return true;
}
if (obj == null || !obj.getClass().equals(Operation.class)) {
return false;
}
Operation other = (Operation) obj;
return Objects.equals(toPb(), other.toPb()) && Objects.equals(options, other.options);
}

com.google.api.services.compute.model.Operation toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ public final int hashCode() {

@Override
public final boolean equals(Object obj) {
return obj instanceof Region && Objects.equals(toPb(), ((Region) obj).toPb());
return obj == this
|| obj != null
&& obj.getClass().equals(Region.class)
&& Objects.equals(toPb(), ((Region) obj).toPb());
}

com.google.api.services.compute.model.Region toPb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,14 @@ public Builder toBuilder() {

@Override
public final boolean equals(Object obj) {
return obj instanceof Snapshot
&& Objects.equals(toPb(), ((Snapshot) obj).toPb())
&& Objects.equals(options, ((Snapshot) obj).options);
if (obj == this) {
return true;
}
if (obj == null || !obj.getClass().equals(Snapshot.class)) {
return false;
}
Snapshot other = (Snapshot) obj;
return Objects.equals(toPb(), other.toPb()) && Objects.equals(options, other.options);
}

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

@Override
public final boolean equals(Object obj) {
return obj instanceof SnapshotDiskConfiguration && baseEquals((SnapshotDiskConfiguration) obj);
return obj == this
|| obj != null
&& obj.getClass().equals(SnapshotDiskConfiguration.class)
&& baseEquals((SnapshotDiskConfiguration) obj);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
return obj != null
return obj == this
|| obj != null
&& obj.getClass().equals(SnapshotInfo.class)
&& Objects.equals(toPb(), ((SnapshotInfo) obj).toPb());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public final int hashCode() {

@Override
public final boolean equals(Object obj) {
return obj instanceof StandardDiskConfiguration && baseEquals((StandardDiskConfiguration) obj);
return obj == this
|| obj != null
&& obj.getClass().equals(StandardDiskConfiguration.class)
&& baseEquals((StandardDiskConfiguration) obj);
}

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

@Override
public final boolean equals(Object obj) {
return obj instanceof StorageImageConfiguration && baseEquals((StorageImageConfiguration) obj);
return obj == this
|| obj != null
&& obj.getClass().equals(StorageImageConfiguration.class)
&& Objects.equals(toPb(), ((StorageImageConfiguration) obj).toPb());
}

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

@Override
public final boolean equals(Object obj) {
return obj instanceof Zone && Objects.equals(toPb(), ((Zone) obj).toPb());
return obj == this
|| obj != null
&& obj.getClass().equals(Zone.class)
&& Objects.equals(toPb(), ((Zone) obj).toPb());
}

com.google.api.services.compute.model.Zone toPb() {
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 ZoneOperationId
&& baseEquals((ZoneOperationId) obj)
&& Objects.equals(zone, ((ZoneOperationId) obj).zone);
if (obj == this) {
return true;
}
if (!(obj instanceof ZoneOperationId)) {
return false;
}
ZoneOperationId other = (ZoneOperationId) obj;
return baseEquals(other) && Objects.equals(zone, other.zone);
}

@Override
Expand Down

0 comments on commit f0ae430

Please sign in to comment.