Ignore:
Timestamp:
12/20/11 13:37:14 (13 years ago)
Author:
sherbold
Message:
  • made de.ugoe.cs.eventbench.data.Event and ReplayableEvent? more robust against incorrect usage, with focus on incorrect subclassing. Especially unexpected null values are now handled more reliably.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/Event.java

    r335 r336  
    9696                if (other instanceof Event<?>) { 
    9797                        Event<?> otherEvent = (Event<?>) other; 
    98                         if (target != null) { 
    99                                 return type.equals(otherEvent.type) 
    100                                                 && target.equals(otherEvent.target); 
     98                        if (otherEvent.canEqual(this)) { 
     99                                if (type != null && target != null) { 
     100                                        return type.equals(otherEvent.type) 
     101                                                        && target.equals(otherEvent.target); 
     102                                } else if (type != null && target == null) { 
     103                                        return type.equals(otherEvent.type) 
     104                                                        && otherEvent.target == null; 
     105                                } else if (type == null && target != null) { 
     106                                        return otherEvent.type == null 
     107                                                        && target.equals(otherEvent.target); 
     108                                } else { 
     109                                        return otherEvent.type == null && otherEvent.target == null; 
     110                                } 
    101111                        } else { 
    102                                 return type.equals(otherEvent.type) 
    103                                                 && otherEvent.target == null; 
     112                                return false; 
    104113                        } 
    105114                } else { 
    106115                        return false; 
    107116                } 
     117        } 
     118 
     119        public boolean canEqual(Object other) { 
     120                return (other instanceof Event<?>); 
    108121        } 
    109122 
     
    216229                int multiplier = 17; 
    217230                int hash = 42; 
    218                 hash = multiplier * hash + type.hashCode(); 
     231                if (type != null) { 
     232                        hash = multiplier * hash + type.hashCode(); 
     233                } 
    219234                if (target != null) { 
    220235                        hash = multiplier * hash + target.hashCode(); 
Note: See TracChangeset for help on using the changeset viewer.