add typesafe wrap variant for classes

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1525724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2013-09-23 22:51:57 +00:00
parent 1cbba96f16
commit 76fd4f1e72
2 changed files with 13 additions and 0 deletions

View File

@ -1556,6 +1556,17 @@ public class TypeUtils {
};
}
/**
* Wrap the specified {@link Class} in a {@link Typed} wrapper.
*
* @param T generic type
* @param type to wrap
* @return Typed<T>
*/
public static <T> Typed<T> wrap(final Class<T> type) {
return TypeUtils.<T> wrap((Type) type);
}
private static String classToString(Class<?> c) {
final StringBuilder buf = new StringBuilder();

View File

@ -720,6 +720,8 @@ public class TypeUtilsTest<B> {
public void testWrap() {
final Type t = getClass().getTypeParameters()[0];
Assert.assertTrue(TypeUtils.equals(t, TypeUtils.wrap(t).getType()));
Assert.assertEquals(String.class, TypeUtils.wrap(String.class).getType());
}
public Iterable<? extends Map<Integer, ? extends Collection<?>>> iterable;