bug 10650: making sure that only unique Nics are added to the set

This commit is contained in:
Abhinandan Prateek 2011-07-08 20:18:22 +05:30 committed by root
parent aa757f0303
commit 2fe48b5359
2 changed files with 45 additions and 4 deletions

View File

@ -144,7 +144,28 @@ public class NicResponse extends BaseResponse {
}
@Override
public boolean equals(Object r){
return (r instanceof NicResponse) && id==((NicResponse)r).id;
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
NicResponse other = (NicResponse) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}

View File

@ -133,7 +133,27 @@ public class SecurityGroupResponse extends BaseResponse {
}
@Override
public boolean equals(Object r){
return (r instanceof SecurityGroupResponse) && id==((SecurityGroupResponse)r).id;
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SecurityGroupResponse other = (SecurityGroupResponse) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}