sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / AnnotationElement.java
index a53f1ee..05aec77 100644 (file)
@@ -201,6 +201,8 @@ implements java.io.Serializable
         if (obj instanceof AnnotationElement) {
         
             AnnotationElement temp = (AnnotationElement)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._position != temp._position)
                 return false;
             if (this._has_position != temp._has_position)
@@ -211,31 +213,91 @@ implements java.io.Serializable
                 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._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._glyphList != null) {
                 if (temp._glyphList == null) return false;
-                else if (!(this._glyphList.equals(temp._glyphList))) 
-                    return false;
-            }
-            else if (temp._glyphList != null)
+                if (this._glyphList != temp._glyphList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._glyphList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._glyphList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._glyphList.equals(temp._glyphList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
+                    }
+                }
+            } else if (temp._glyphList != null)
                 return false;
             if (this._valueList != null) {
                 if (temp._valueList == null) return false;
-                else if (!(this._valueList.equals(temp._valueList))) 
-                    return false;
-            }
-            else if (temp._valueList != null)
+                if (this._valueList != temp._valueList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._valueList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._valueList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._valueList.equals(temp._valueList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
+                    }
+                }
+            } else if (temp._valueList != null)
                 return false;
             return true;
         }
@@ -442,17 +504,25 @@ implements java.io.Serializable
         long tmp;
         result = 37 * result + (int)(_position^(_position>>>32));
         result = 37 * result + (_after?0:1);
-        if (_id != null) {
+        if (_id != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
            result = 37 * result + _id.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_id);
         }
-        if (_description != null) {
+        if (_description != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_description)) {
            result = 37 * result + _description.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_description);
         }
-        if (_glyphList != null) {
+        if (_glyphList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_glyphList)) {
            result = 37 * result + _glyphList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_glyphList);
         }
-        if (_valueList != null) {
+        if (_valueList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_valueList)) {
            result = 37 * result + _valueList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_valueList);
         }
         
         return result;