+
+ boolean improved=false;
+ /*
+ * source must either match or be both null
+ */
+ String otherSource = other.getSource();
+ if ((source == null && otherSource != null)
+ || (source != null && otherSource == null)
+ || (source != null && !source.equalsIgnoreCase(otherSource)))
+ {
+ return false;
+ }
+
+ /*
+ * accession id must either match or be both null
+ */
+ String otherAccession = other.getAccessionId();
+ if ((accessionId == null && otherAccession != null)
+ || (accessionId != null && otherAccession == null)
+ || (accessionId != null
+ && !accessionId.equalsIgnoreCase(otherAccession)))
+ {
+ return false;
+ }
+
+ if (!isCanonicalAccession && other.isCanonical())
+ {
+ isCanonicalAccession = true;
+ improved = true;
+ }
+ else
+ {
+ if (isCanonicalAccession && !other.isCanonical())
+ {
+ // other is not an authoritative source of canonical accessions
+ return false;
+ }
+ }
+ /*
+ * if my version is null, "0" or "source:0" then replace with other version,
+ * otherwise the versions have to match
+ */
+ String otherVersion = other.getVersion();
+
+ if ((version == null || version.equals("0") || version.endsWith(":0"))
+ && otherVersion != null)
+ {
+ setVersion(otherVersion);
+ }
+ else
+ {
+ if (version != null && (otherVersion == null
+ || !version.equalsIgnoreCase(otherVersion)))
+ {
+ // FIXME: there may be a problem with old version strings not allowing
+ // updating of dbrefentries
+ return improved;
+ }
+ }
+
+ /*
+ * if I have no mapping, take that of the other dbref
+ * - providing it had a version and so do I
+ */
+ if (map == null)
+ {
+ setMap(other.getMap());
+ }
+ return true;