sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / VAMSAS.java
index ba8146f..a762b20 100644 (file)
@@ -160,33 +160,95 @@ implements java.io.Serializable
         if (obj instanceof VAMSAS) {
         
             VAMSAS temp = (VAMSAS)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._id != null) {
                 if (temp._id == null) return false;
-                else if (!(this._id.equals(temp._id))) 
-                    return false;
-            }
-            else if (temp._id != null)
+                if (this._id != temp._id) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._id.equals(temp._id)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
+                    }
+                }
+            } else if (temp._id != null)
                 return false;
             if (this._modifiable != null) {
                 if (temp._modifiable == null) return false;
-                else if (!(this._modifiable.equals(temp._modifiable))) 
-                    return false;
-            }
-            else if (temp._modifiable != null)
+                if (this._modifiable != temp._modifiable) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._modifiable);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._modifiable);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._modifiable.equals(temp._modifiable)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
+                    }
+                }
+            } else if (temp._modifiable != null)
                 return false;
             if (this._treeList != null) {
                 if (temp._treeList == null) return false;
-                else if (!(this._treeList.equals(temp._treeList))) 
-                    return false;
-            }
-            else if (temp._treeList != null)
+                if (this._treeList != temp._treeList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._treeList.equals(temp._treeList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList);
+                    }
+                }
+            } else if (temp._treeList != null)
                 return false;
             if (this._dataSetList != null) {
                 if (temp._dataSetList == null) return false;
-                else if (!(this._dataSetList.equals(temp._dataSetList))) 
-                    return false;
-            }
-            else if (temp._dataSetList != null)
+                if (this._dataSetList != temp._dataSetList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dataSetList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dataSetList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._dataSetList.equals(temp._dataSetList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._dataSetList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._dataSetList);
+                    }
+                }
+            } else if (temp._dataSetList != null)
                 return false;
             return true;
         }
@@ -342,17 +404,25 @@ implements java.io.Serializable
         int result = super.hashCode();
         
         long tmp;
-        if (_id != null) {
+        if (_id != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
            result = 37 * result + _id.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_id);
         }
-        if (_modifiable != null) {
+        if (_modifiable != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) {
            result = 37 * result + _modifiable.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable);
         }
-        if (_treeList != null) {
+        if (_treeList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) {
            result = 37 * result + _treeList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_treeList);
         }
-        if (_dataSetList != null) {
+        if (_dataSetList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_dataSetList)) {
            result = 37 * result + _dataSetList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_dataSetList);
         }
         
         return result;