X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FDBRefEntry.java;h=738c4dc831caf71090ddf09bd57ff458f468be44;hb=0ebcd487f08f9873987d9a32edce7df47aa27927;hp=53642b530103bcb9c4ec61fd704da87481857cf8;hpb=f213422632d268e3a2f334255fa705d8e931866f;p=jalview.git diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 53642b5..738c4dc 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -98,6 +98,82 @@ public class DBRefEntry implements DBRefEntryI } /** + * Answers true if this object is either equivalent to, or can be 'improved' + * by, the given entry. Specifically, answers true if + * + * + * @param other + * @return + */ + @Override + public boolean updateFrom(DBRefEntry other) + { + if (other == null) + { + return false; + } + if (other == this) + { + return true; + } + + /* + * 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 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.equalsIgnoreCase(otherVersion)) + { + return false; + } + } + + /* + * if I have no mapping, take that of the other dbref + */ + if (map == null) + { + setMap(other.getMap()); + } + return true; + } + + /** * test for similar DBRef attributes, except for the map object. * * @param entry @@ -106,6 +182,7 @@ public class DBRefEntry implements DBRefEntryI @Override public boolean equalRef(DBRefEntryI entry) { + // TODO is this method and equals() not needed? if (entry == null) { return false;