- this(new String(entry.source), new String(entry.version), new String(entry.accessionId), new Mapping(entry.map));
- }
- public boolean equals(DBRefEntry entry) {
- if (entry==this)
- return true;
- if (entry==null)
- return false;
- if ((source!=null && entry.source!=null && source.equals(entry.source))
- &&
- (accessionId!=null && entry.accessionId!=null && accessionId.equals(entry.accessionId))
- &&
- (version!=null && entry.version!=null && version.equals(entry.version))
- &&
- ((map==null && entry.map==null) || (map!=null && entry.map!=null && map.equals(entry.map)))) {
- return true;
- }
+ this(
+ (entry.source == null ? "" : new String(entry.source)),
+ (entry.version == null ? "" : new String(entry.version)),
+ (entry.accessionId == null ? "" : new String(entry.accessionId)),
+ (entry.map == null ? null : new Mapping(entry.map)));
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ // TODO should also override hashCode to ensure equal objects have equal
+ // hashcodes
+ if (o == null || !(o instanceof DBRefEntry))
+ {
+ return false;
+ }
+ DBRefEntry entry = (DBRefEntry) o;
+ if (entry == this)
+ {
+ return true;
+ }
+ if (equalRef(entry)
+ && ((map == null && entry.map == null) || (map != null
+ && entry.map != null && map.equals(entry.map))))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * test for similar DBRef attributes, except for the map object.
+ *
+ * @param entry
+ * @return true if source, accession and version are equal with those of entry
+ */
+ public boolean equalRef(DBRefEntry entry)
+ {
+ if (entry == null)
+ {