@@ -0,0 +1,1398 @@
+%0Apackage net.restlesscoder.sandbox;%0A%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0Aimport net.imglib2.type.NativeType;%0Aimport net.imglib2.type.numeric.RealType;%0A%0Aimport org.scijava.Disposable;%0Aimport org.scijava.Prioritized;%0A%0A/**%0A * Demonstrates calling a method with type intersections via type variables.%0A * Note that it %3Cem%3Edoes not work%3C/em%3E with recursive generics!%0A */%0Apublic class TypeIntersections %7B%0A%0A%09public static %3CT extends Disposable & Prioritized%3E void simple(T t) %7B%0A%09%09t.getPriority();%0A%09%09t.dispose();%0A%09%7D%0A%0A%09public static %3CE, T extends List%3CE%3E & Set%3CE%3E%3E void generic(T t) %7B%0A%09%09t.get(0);%0A%09%7D%0A%09public static %3CT extends RealType%3CT%3E & NativeType%3CT%3E%3E void recursive(T t) %7B%0A%09%09t.getRealDouble();%0A%09%09t.getEntitiesPerPixel();%0A%09%7D%0A%0A%09public static void nonGenericIntersection() %7B%0A%09%09final Object o = new Object();%0A%09%09// simple(o); // compile error%0A%09%09// simple((Disposable) o); // compile error%0A%09%09simple((Disposable & Prioritized) o); // works%0A%09%7D%0A%0A%09public static %3CE, T extends List%3CE%3E & Set%3CE%3E%3E void genericIntersection() %7B%0A%09%09final Object o = new Object();%0A%09%09// generic(o); // compile error%0A%09%09generic((List%3CE%3E & Set%3CE%3E) o); // compiler warning, but allowed%0A%09%7D%0A%0A%09public static %3CT extends RealType%3CT%3E & NativeType%3CT%3E%3E void%0A%09%09recursiveGenericIntersection()%0A%09%7B%0A%09%09final Object o = new Object();%0A%09%09// recursive(o); // compile error%0A%09%09// recursive((RealType%3CT%3E & NativeType%3CT%3E) o); // shockingly, an error!%0A%09%7D%0A%7D%0A

Add a demonstration of type intersections