Changeset 373


Ignore:
Timestamp:
01/30/12 15:40:38 (12 years ago)
Author:
sherbold
Message:
  • extended de.ugoe.cs.eventbench.data.Event with a function targetEquals() that can be overridden by subclasses to allow sophisticated target comparisons instead of simple string comparisons.
File:
1 edited

Legend:

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

    r336 r373  
    9797                        Event<?> otherEvent = (Event<?>) other; 
    9898                        if (otherEvent.canEqual(this)) { 
    99                                 if (type != null && target != null) { 
     99                                if (type != null) { 
    100100                                        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) { 
     101                                                        && targetEquals(otherEvent.target); 
     102                                } else { 
    106103                                        return otherEvent.type == null 
    107                                                         && target.equals(otherEvent.target); 
    108                                 } else { 
    109                                         return otherEvent.type == null && otherEvent.target == null; 
     104                                                        && targetEquals(otherEvent.target); 
    110105                                } 
    111106                        } else { 
     
    287282                return true; 
    288283        } 
     284 
     285        /** 
     286         * <p> 
     287         * This function is used by {@link #equals(Object)} to determine if the 
     288         * targets of both events are equal. The standard implementation provided by 
     289         * this class performs a String comparison between the target strings. 
     290         * </p> 
     291         * <p> 
     292         * Subclasses can override this method to implemented more sophisticated 
     293         * means for the target comparison, e.g., to account for changes in the 
     294         * title of a widget. 
     295         * </p> 
     296         *  
     297         * @param otherTarget 
     298         * @return 
     299         */ 
     300        protected boolean targetEquals(String otherTarget) { 
     301                boolean retVal; 
     302                if (target != null) { 
     303                        retVal = target.equals(otherTarget); 
     304                } else { 
     305                        retVal = (otherTarget == null); 
     306                } 
     307                return retVal; 
     308        } 
    289309} 
Note: See TracChangeset for help on using the changeset viewer.