sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / SequenceType.java
index 6b25c6f..1a89b6c 100644 (file)
@@ -153,6 +153,8 @@ implements java.io.Serializable
         if (obj instanceof SequenceType) {
         
             SequenceType temp = (SequenceType)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._start != temp._start)
                 return false;
             if (this._has_start != temp._has_start)
@@ -163,31 +165,91 @@ implements java.io.Serializable
                 return false;
             if (this._sequence != null) {
                 if (temp._sequence == null) return false;
-                else if (!(this._sequence.equals(temp._sequence))) 
-                    return false;
-            }
-            else if (temp._sequence != null)
+                if (this._sequence != temp._sequence) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._sequence);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._sequence);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._sequence.equals(temp._sequence)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._sequence);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequence);
+                    }
+                }
+            } else if (temp._sequence != null)
                 return false;
             if (this._name != null) {
                 if (temp._name == null) return false;
-                else if (!(this._name.equals(temp._name))) 
-                    return false;
-            }
-            else if (temp._name != null)
+                if (this._name != temp._name) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._name);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._name);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._name); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._name); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._name.equals(temp._name)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
+                    }
+                }
+            } else if (temp._name != null)
                 return false;
             if (this._description != null) {
                 if (temp._description == null) return false;
-                else if (!(this._description.equals(temp._description))) 
-                    return false;
-            }
-            else if (temp._description != null)
+                if (this._description != temp._description) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._description.equals(temp._description)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
+                    }
+                }
+            } else if (temp._description != null)
                 return false;
             if (this._propertyList != null) {
                 if (temp._propertyList == null) return false;
-                else if (!(this._propertyList.equals(temp._propertyList))) 
-                    return false;
-            }
-            else if (temp._propertyList != null)
+                if (this._propertyList != temp._propertyList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._propertyList.equals(temp._propertyList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
+                    }
+                }
+            } else if (temp._propertyList != null)
                 return false;
             return true;
         }
@@ -336,17 +398,25 @@ implements java.io.Serializable
         long tmp;
         result = 37 * result + (int)(_start^(_start>>>32));
         result = 37 * result + (int)(_end^(_end>>>32));
-        if (_sequence != null) {
+        if (_sequence != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_sequence)) {
            result = 37 * result + _sequence.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_sequence);
         }
-        if (_name != null) {
+        if (_name != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_name)) {
            result = 37 * result + _name.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_name);
         }
-        if (_description != null) {
+        if (_description != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_description)) {
            result = 37 * result + _description.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_description);
         }
-        if (_propertyList != null) {
+        if (_propertyList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) {
            result = 37 * result + _propertyList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList);
         }
         
         return result;