/**
* Created by IntelliJ IDEA.
* User: me
* Date: 15.09.2006
* Time: 17:09:07
* To change this template use File | Settings | File Templates.
*/
private long id;
private transient int hash;
private static long nextID = 0;
public BetterName
(String name
) { this.name = name;
synchronized (BetterName.class) {
id = nextID++;
}
hash = name.hashCode();
}
out.writeUTF(name);
out.writeLong(id);
// Alternative:
//out.defaultWriteObject();
}
{
name = in.readUTF();
id = in.readLong();
// Alternative:
//in.defaultReadObject();
hash = name.hashCode();
}
public int hashCode() {
return hash;
}
}