View Full Version : Hashcode() and equals()

29 Feb 2012, 4:31 AM

I have overwritten hashCode() and equals() for subclasses of BaseTreeModel and BaseModelData. It seems, that a lot of methods within TreeGrid and TreeStore go wrong. Both classes hold some type of cache or wrapper lists, which can not find changed models. I have changed some properties of a model and the hashcode has been re-calculated. So I don't get the parent of a model nor I can update a changed model within the store.

Is it not possible to reimplement both methods when using GXT? The implementation follows this example:

public int hashCode() {
return get("property") == null ? 0 : get("property").hashCode();

public boolean equals(Object other) {
if (this == other) {
return true;
if (!(other instanceof Thing)) {
return false;
Thing t = (Thing) other;
return ((get("property") == null) ? t.get("property") == null : get("property").equals(t.get("property")));


29 Feb 2012, 5:57 AM
It seems, that the following is a good workaround:

1. find the model within the store
2. save the index of the model
3. remove the model
4. change the model's properties
5. re-insert the model on index


don't override hashCode() nor equals /:).