Adding URL based equals and hashcode to BaseResourceBean.
This commit is contained in:
parent
dd84a0ddf4
commit
7731df5235
1 changed files with 23 additions and 0 deletions
|
@ -207,4 +207,27 @@ public class BaseResourceBean implements ResourceBean {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if(obj == null )
|
||||||
|
return false;
|
||||||
|
else if (obj instanceof BaseResourceBean ){
|
||||||
|
String thisURI = this.getURI();
|
||||||
|
String thatURI = ((BaseResourceBean)obj).getURI();
|
||||||
|
if( thisURI != null && thatURI != null ){
|
||||||
|
return thisURI.equals(thatURI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj.hashCode() == this.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
if( getURI() != null )
|
||||||
|
return getURI().hashCode();
|
||||||
|
else
|
||||||
|
return super.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue