Author: adrianc
Date: Sat Mar 21 12:36:44 2015
New Revision: 1668257
URL: http://svn.apache.org/r1668257
Log:
Some work on GenericEntity and its subclasses: Enforce GenericPK !=
GenericEntity and GenericValue != GenericEntity.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=1668257&r1=1668256&r2=1668257&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java
(original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Sat
Mar 21 12:36:44 2015
@@ -1276,14 +1276,14 @@ public class GenericEntity implements Ma
*/
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof GenericEntity)) return false;
-
- // from here, use the compareTo method since it is more efficient:
- try {
- return this.compareTo((GenericEntity) obj) == 0;
- } catch (ClassCastException e) {
- return false;
+ if (obj == this) {
+ return true;
+ }
+ if (obj instanceof GenericEntity) {
+ GenericEntity that = (GenericEntity) obj;
+ return this.entityName.equals(that.entityName) &&
this.fields.equals(that.fields);
}
+ return false;
}
/** Creates a hashCode for the entity, using the default String hashCode
and Map hashCode, overrides the default hashCode
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java?rev=1668257&r1=1668256&r2=1668257&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericPK.java Sat Mar 21
12:36:44 2015
@@ -59,6 +59,14 @@ public class GenericPK extends GenericEn
return newPK;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof GenericPK) {
+ return super.equals(obj);
+ }
+ return false;
+ }
+
/** Clones this GenericPK, this is a shallow clone & uses the default
shallow HashMap clone
*@return Object that is a clone of this GenericPK
*/
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java?rev=1668257&r1=1668256&r2=1668257&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java
(original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Sat Mar
21 12:36:44 2015
@@ -305,6 +305,14 @@ public class GenericValue extends Generi
return this.getDelegator().getRelatedDummyPK(relationName,
byAndFields, this);
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof GenericValue) {
+ return super.equals(obj);
+ }
+ return false;
+ }
+
/** Clones this GenericValue, this is a shallow clone & uses the default
shallow HashMap clone
*@return Object that is a clone of this GenericValue
*/