| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.ui.internal.dialogs; |
| 12 | |
| 13 | import org.eclipse.core.runtime.IAdaptable; |
| 14 | import org.eclipse.ui.internal.util.Util; |
| 15 | |
| 16 | /** |
| 17 | * Class that wraps an object and forwards adapter calls if possible, otherwise |
| 18 | * returns the object. This is used to maintain API compatibility with methods that |
| 19 | * need an IAdaptable but when the operation supports a broader type. |
| 20 | * |
| 21 | * @since 3.2 |
| 22 | */ |
| 23 | public class AdaptableForwarder implements IAdaptable { |
| 24 | |
| 25 | private Object element; |
| 26 | |
| 27 | /** |
| 28 | * Create a new instance of the receiver. |
| 29 | * @param element |
| 30 | */ |
| 31 | public AdaptableForwarder(Object element) { |
| 32 | this.element = element; |
| 33 | } |
| 34 | |
| 35 | /* (non-Javadoc) |
| 36 | * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
| 37 | */ |
| 38 | public Object getAdapter(Class adapter) { |
| 39 | return Util.getAdapter(element, adapter); |
| 40 | } |
| 41 | } |