sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Newick.java
index 23d4f82..2813c56 100644 (file)
@@ -81,33 +81,95 @@ implements java.io.Serializable
         if (obj instanceof Newick) {
         
             Newick temp = (Newick)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._content != null) {
                 if (temp._content == null) return false;
-                else if (!(this._content.equals(temp._content))) 
-                    return false;
-            }
-            else if (temp._content != null)
+                if (this._content != temp._content) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._content.equals(temp._content)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._content);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);
+                    }
+                }
+            } else if (temp._content != null)
                 return false;
             if (this._title != null) {
                 if (temp._title == null) return false;
-                else if (!(this._title.equals(temp._title))) 
-                    return false;
-            }
-            else if (temp._title != null)
+                if (this._title != temp._title) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._title);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._title);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._title); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._title); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._title.equals(temp._title)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
+                    }
+                }
+            } else if (temp._title != null)
                 return false;
             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;
             return true;
         }
@@ -171,17 +233,25 @@ implements java.io.Serializable
         int result = super.hashCode();
         
         long tmp;
-        if (_content != null) {
+        if (_content != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_content)) {
            result = 37 * result + _content.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_content);
         }
-        if (_title != null) {
+        if (_title != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_title)) {
            result = 37 * result + _title.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_title);
         }
-        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);
         }
         
         return result;