Code example for EventObject

Methods: getSource

0
        this.eventClass = eventClass;
        this.source = source;
    } 
 
    @Override 
    public boolean matchesSafely(EventObject item, Description mismatchDescription) {
        if (!eventClass.isInstance(item)) {
          mismatchDescription.appendText("item type was " + item.getClass().getName());
          return false; 
        } 
         
        if (!eventHasSameSource(item)) {
          mismatchDescription.appendText("source was ").appendValue(item.getSource());
          return false; 
        } 
        return true; 
    } 
 
     
    private boolean eventHasSameSource(EventObject ev) {
        return ev.getSource() == source;