sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Alignment.java
index 277be27..ffafc47 100644 (file)
@@ -280,12 +280,29 @@ implements java.io.Serializable
         if (obj instanceof Alignment) {
         
             Alignment temp = (Alignment)obj;
+            boolean thcycle;
+            boolean tmcycle;
             if (this._gapChar != null) {
                 if (temp._gapChar == null) return false;
-                else if (!(this._gapChar.equals(temp._gapChar))) 
-                    return false;
-            }
-            else if (temp._gapChar != null)
+                if (this._gapChar != temp._gapChar) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._gapChar);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._gapChar);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._gapChar.equals(temp._gapChar)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._gapChar);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._gapChar);
+                    }
+                }
+            } else if (temp._gapChar != null)
                 return false;
             if (this._aligned != temp._aligned)
                 return false;
@@ -293,52 +310,157 @@ 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._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._alignmentAnnotationList != null) {
                 if (temp._alignmentAnnotationList == null) return false;
-                else if (!(this._alignmentAnnotationList.equals(temp._alignmentAnnotationList))) 
-                    return false;
-            }
-            else if (temp._alignmentAnnotationList != null)
+                if (this._alignmentAnnotationList != temp._alignmentAnnotationList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentAnnotationList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentAnnotationList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentAnnotationList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentAnnotationList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._alignmentAnnotationList.equals(temp._alignmentAnnotationList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentAnnotationList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentAnnotationList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentAnnotationList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentAnnotationList);
+                    }
+                }
+            } else if (temp._alignmentAnnotationList != 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._alignmentSequenceList != null) {
                 if (temp._alignmentSequenceList == null) return false;
-                else if (!(this._alignmentSequenceList.equals(temp._alignmentSequenceList))) 
-                    return false;
-            }
-            else if (temp._alignmentSequenceList != null)
+                if (this._alignmentSequenceList != temp._alignmentSequenceList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentSequenceList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentSequenceList);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceList); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._alignmentSequenceList.equals(temp._alignmentSequenceList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceList);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceList);
+                    }
+                }
+            } else if (temp._alignmentSequenceList != 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;
             if (this._provenance != null) {
                 if (temp._provenance == null) return false;
-                else if (!(this._provenance.equals(temp._provenance))) 
-                    return false;
-            }
-            else if (temp._provenance != null)
+                if (this._provenance != temp._provenance) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance);
+                    if (thcycle!=tmcycle) {
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); };
+                        return false;
+                    }
+                    if (!thcycle) {
+                        if (!this._provenance.equals(temp._provenance)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
+                            return false;
+                        }
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
+                    }
+                }
+            } else if (temp._provenance != null)
                 return false;
             return true;
         }
@@ -652,30 +774,46 @@ implements java.io.Serializable
         int result = super.hashCode();
         
         long tmp;
-        if (_gapChar != null) {
+        if (_gapChar != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_gapChar)) {
            result = 37 * result + _gapChar.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_gapChar);
         }
         result = 37 * result + (_aligned?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 (_modifiable != null) {
+        if (_modifiable != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) {
            result = 37 * result + _modifiable.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable);
         }
-        if (_alignmentAnnotationList != null) {
+        if (_alignmentAnnotationList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_alignmentAnnotationList)) {
            result = 37 * result + _alignmentAnnotationList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentAnnotationList);
         }
-        if (_treeList != null) {
+        if (_treeList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) {
            result = 37 * result + _treeList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_treeList);
         }
-        if (_alignmentSequenceList != null) {
+        if (_alignmentSequenceList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_alignmentSequenceList)) {
            result = 37 * result + _alignmentSequenceList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentSequenceList);
         }
-        if (_propertyList != null) {
+        if (_propertyList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) {
            result = 37 * result + _propertyList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList);
         }
-        if (_provenance != null) {
+        if (_provenance != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
            result = 37 * result + _provenance.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
         }
         
         return result;