/******************************************************************************* * 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.finder.matchers; import abbot.finder.swt.Matcher; import com.windowtester.runtime.locator.IWidgetMatcher; /** * A service for adapting {@link IWidgetMatcher}s to Abbot * {@link Matcher}s and vice versa. * */ public class AdapterFactory /* extends swing adapter factory */ { //TODO: consider singleton vs. monostate /** * Adapt this <code>IWidgetMatcher</code> to a <code>Matcher</code>. */ public Matcher adapt(IWidgetMatcher matcher) { if (matcher instanceof Matcher) return (Matcher)matcher; return new SWTFinderMatcherAdapter(matcher); } /** * Adapt this <code>Matcher</code> to a <code>IWidgetMatcher</code>. */ public IWidgetMatcher adapt(Matcher matcher) { if (matcher instanceof IWidgetMatcher) return (IWidgetMatcher)matcher; return new WidgetMatcherAdapter(matcher); } }