dion 2002/06/24 06:41:29
Modified: src/java/org/apache/maven/project BaseObject.java
Log:
Added equals and hashcode
Revision Changes Path
1.6 +48 -1
jakarta-turbine-maven/src/java/org/apache/maven/project/BaseObject.java
Index: BaseObject.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/project/BaseObject.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BaseObject.java 21 Jun 2002 04:17:29 -0000 1.5
+++ BaseObject.java 24 Jun 2002 13:41:29 -0000 1.6
@@ -121,4 +121,51 @@
{
return name;
}
+
+ /**
+ * Whether the passed object is the same as this one. In this case
+ * the id is the unique qualifier. So two objects are equal
+ * if they have equal id's
+ * @param o any object
+ * @return true if o is the same as this object, false otherwise
+ */
+ public boolean equals(Object o)
+ {
+ if (o == null)
+ {
+ return false;
+ }
+
+ if (getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ if (getId() != null)
+ {
+ return getId().equals(((BaseObject) o).getId());
+ }
+ else
+ {
+ return ((BaseObject) o).getId() == null;
+ }
+ }
+
+ /** provides the hashCode of this object, which is determined by simply
+ * delegating the responsibility to the name property
+ * @return the hashCode of the name if not null, otherwise delegate to the
+ * parent class
+ */
+ public int hashCode()
+ {
+ if (getId() != null)
+ {
+ return getId().hashCode();
+ }
+ else
+ {
+ return super.hashCode();
+ }
+ }
+
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>