reversed comparison of type and id in Key.equals()

This commit is contained in:
hns 2001-02-23 23:58:37 +00:00
parent 35d118c43c
commit bf8397634c

View file

@ -13,7 +13,7 @@ import java.io.Serializable;
* key of the node and unique within each HOP application. Currently only * key of the node and unique within each HOP application. Currently only
* single keys are supported. * single keys are supported.
*/ */
public final class Key implements Serializable { public class Key {
protected String type; protected String type;
protected String id; protected String id;
@ -29,13 +29,13 @@ public final class Key implements Serializable {
public Key (String type, String id) { public Key (String type, String id) {
this.type = type; this.type = type;
this.id = id; this.id = id;
hash = this.id.hashCode (); hash = id.hashCode ();
} }
public boolean equals (Object what) { public boolean equals (Object what) {
try { try {
Key k = (Key) what; Key k = (Key) what;
return (id == k.id || id.equals (k.id)) && (type == k.type || type.equals (k.type)); return ((type == k.type || type.equals (k.type)) && (id == k.id || id.equals (k.id)));
} catch (Exception x) { } catch (Exception x) {
return false; return false;
} }
@ -61,7 +61,7 @@ public final class Key implements Serializable {
* a key that can't be mistaken for a relational db key. * a key that can't be mistaken for a relational db key.
*/ */
public Key getVirtualKey (String sid) { public Key getVirtualKey (String sid) {
return new Key ("", makeVirtualID (type, id, sid)); return new Key ((String) null, makeVirtualID (type, id, sid));
} }
public String getVirtualID (String sid) { public String getVirtualID (String sid) {
@ -69,7 +69,7 @@ public final class Key implements Serializable {
} }
public static String makeVirtualID (DbMapping pmap, String pid, String sid) { public static String makeVirtualID (DbMapping pmap, String pid, String sid) {
return makeVirtualID (pmap == null ? "" : pmap.typename, pid, sid); return makeVirtualID (pmap == null ? (String) null : pmap.typename, pid, sid);
} }
public static String makeVirtualID (String ptype, String pid, String sid) { public static String makeVirtualID (String ptype, String pid, String sid) {