@@ -0,0 +1,1134 @@
+package org.metaborg.util.inject;%0A%0Aimport java.lang.reflect.ParameterizedType;%0Aimport java.lang.reflect.Type;%0A%0Aimport com.google.inject.Injector;%0Aimport com.google.inject.Key;%0Aimport com.google.inject.TypeLiteral;%0Aimport com.google.inject.util.Types;%0A%0Apublic class GenericInjectUtils %7B%0A    public static %3CT%3E Key%3CT%3E key(Type rawType, Type... typeArgs) %7B%0A        final ParameterizedType type = Types.newParameterizedType(rawType, typeArgs);%0A        @SuppressWarnings(%22unchecked%22) final Key%3CT%3E key = (Key%3CT%3E) Key.get(type);%0A        return key;%0A    %7D%0A%0A    public static %3CT%3E Key%3CT%3E key(TypeLiteral%3CT%3E typeLiteral, Type... typeArgs) %7B%0A        final Class%3C? super T%3E rawType = typeLiteral.getRawType();%0A        return key(rawType, typeArgs);%0A    %7D%0A%0A%0A    public static %3CT%3E T instance(Injector injector, Type rawType, Type... typeArgs) %7B%0A        final Key%3CT%3E key = key(rawType, typeArgs);%0A        return injector.getInstance(key);%0A    %7D%0A%0A    public static %3CT%3E T instance(Injector injector, TypeLiteral%3CT%3E typeLiteral, Type... typeArgs) %7B%0A        final Key%3CT%3E key = key(typeLiteral, typeArgs);%0A        return injector.getInstance(key);%0A    %7D%0A%7D%0A

Add utility class for instantiating generic classes from a Guice injector.