From 7731df5235db179034e55c6327771e5a9aee9535 Mon Sep 17 00:00:00 2001 From: bdc34 Date: Tue, 23 Mar 2010 21:58:18 +0000 Subject: [PATCH] Adding URL based equals and hashcode to BaseResourceBean. --- .../vitro/webapp/beans/BaseResourceBean.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/BaseResourceBean.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/BaseResourceBean.java index 285a54a19..7fc85a87c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/BaseResourceBean.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/beans/BaseResourceBean.java @@ -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(); + } + + }