/*******************************************************************************
* Copyright (c) 2012 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package com.windowtester.runtime.swt.internal.matchers;
import com.windowtester.runtime.swt.internal.widgets.ISWTWidgetMatcher;
import com.windowtester.runtime.swt.internal.widgets.ISWTWidgetReference;
/**
* Matches exact widget instances.
*/
public class InstanceMatcher implements ISWTWidgetMatcher {
private final Object widget;
public InstanceMatcher(ISWTWidgetReference<?> ref){
this(ref.getWidget());
}
public InstanceMatcher(Object widget) {
this.widget = widget;
}
/* (non-Javadoc)
* @see com.windowtester.runtime.swt.widgets.ISWTWidgetMatcher#matches(com.windowtester.runtime.swt.widgets.ISWTWidgetReference)
*/
public boolean matches(ISWTWidgetReference<?> ref) {
if (ref == null)
return false;
return ref.getWidget() == widget;
}
}