1. #1
    Sencha User
    Join Date
    Sep 2011
    Location
    Leipzig, Germany
    Posts
    73
    Vote Rating
    0
    A.Rothe is on a distinguished road

      0  

    Question Hashcode() and equals()

    Hashcode() and equals()


    Hi,

    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:

    Code:
        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")));
        }

    Thanks
    Andre

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Location
    Leipzig, Germany
    Posts
    73
    Vote Rating
    0
    A.Rothe is on a distinguished road

      0  

    Default


    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

    or

    don't override hashCode() nor equals .

    ~Andre

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar