Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

Commit 93335de

Browse files
authored
[ggj][codegen][engx] feat: add equals() and hashCode() overrides for ResourceReference (#596)
* fix: fix dep ordering in Bazel dedupe rules * feat: add equals() and hashCode() overrides for ResourceReference
1 parent d8cbb64 commit 93335de

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/main/java/com/google/api/generator/gapic/model/ResourceReference.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ public boolean isOnlyWildcard() {
2828
return resourceTypeString().equals(ResourceNameConstants.WILDCARD_PATTERN);
2929
}
3030

31+
@Override
32+
public boolean equals(Object o) {
33+
if (!(o instanceof ResourceReference)) {
34+
return false;
35+
}
36+
37+
ResourceReference other = (ResourceReference) o;
38+
return resourceTypeString().equals(other.resourceTypeString())
39+
&& isChildType() == other.isChildType()
40+
&& isOnlyWildcard() == other.isOnlyWildcard();
41+
}
42+
43+
@Override
44+
public int hashCode() {
45+
return 17 * resourceTypeString().hashCode()
46+
+ (isChildType() ? 1 : 0) * 19
47+
+ (isOnlyWildcard() ? 1 : 0) * 31;
48+
}
49+
3150
public static ResourceReference withType(String resourceTypeString) {
3251
return builder().setResourceTypeString(resourceTypeString).setIsChildType(false).build();
3352
}

0 commit comments

Comments
 (0)