Skip to content

Commit 1c64044

Browse files
Marcus Sorensenchaturvedia
authored andcommitted
CLOUDSTACK-6089: Implement equals() method for ResourceTagResponse
so that the java Set can properly determine if a ResourceTagResponse is unique. This ensures we don't get duplicate resource tags showing up any time a UserVmResponse is crafted (which can be quite often due to the way the responses are crafted). (cherry picked from commit 06ae237) Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
1 parent a10a083 commit 1c64044

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎api/src/org/apache/cloudstack/api/response/ResourceTagResponse.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,34 @@ public void setProjectName(String projectName) {
101101
public void setCustomer(String customer) {
102102
this.customer = customer;
103103
}
104+
105+
public String getResourceId() {
106+
return this.resourceId;
107+
}
108+
109+
@Override
110+
public int hashCode() {
111+
final int prime = 31;
112+
int result = 1;
113+
String rId = this.getResourceId();
114+
result = prime * result + ((rId== null) ? 0 : rId.hashCode());
115+
return result;
116+
}
117+
118+
@Override
119+
public boolean equals(Object obj) {
120+
if (this == obj)
121+
return true;
122+
if (obj == null)
123+
return false;
124+
if (this.getClass() != obj.getClass())
125+
return false;
126+
ResourceTagResponse other = (ResourceTagResponse) obj;
127+
String rId = this.getResourceId();
128+
if (rId == null && other.getResourceId() != null) {
129+
return false;
130+
} else if (!rId.equals(other.getResourceId()))
131+
return false;
132+
return true;
133+
}
104134
}

0 commit comments

Comments
 (0)