package ccw.util;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;

public final class PlatformUtil {
	private PlatformUtil() {}
	
	/**
	 * First checks if <code>adaptable</code> is a direct instance of 
	 * <code>adapterType</code>, then if it's an instance of 
	 * <code>IAdaptable</code> and if this suffices to get the desired
	 * adaptation to <code>adapterType</code>, or else leverages the
	 * PlatformManager's discovery of adatapers 
	 * @param adaptable
	 * @param adapterType
	 * @return
	 */
	public static Object getAdapter(Object adaptable, Class adapterType) {
		if (adaptable == null || adapterType == null) {
			return null;
		} else if (adapterType.isInstance(adaptable)) {
			return adaptable;
		} else {
			if (adaptable instanceof IAdaptable) {
				Object ret = ((IAdaptable) adaptable).getAdapter(adapterType);
				if (ret != null) {
					return ret;
				}
			}
			return Platform.getAdapterManager().getAdapter(adaptable, adapterType);
		}
	}
}

@@ -550,22 +550,21 @@
  static 
-Object
+%3CT%3E T
  getAdap
@@ -590,16 +590,19 @@
 e, Class
+%3CT%3E
  adapter
@@ -734,16 +734,20 @@
 %09%09return
+ (T)
  adaptab
@@ -904,16 +904,20 @@
 %09%09return
+ (T)
  ret;%0A%09%09
@@ -934,16 +934,20 @@
 %09%09return
+ (T)
  Platfor

use of Generics