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:
parent
1cbba96f16
commit
76fd4f1e72
|
@ -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) {
|
private static String classToString(Class<?> c) {
|
||||||
final StringBuilder buf = new StringBuilder();
|
final StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
|
|
|
@ -720,6 +720,8 @@ public class TypeUtilsTest<B> {
|
||||||
public void testWrap() {
|
public void testWrap() {
|
||||||
final Type t = getClass().getTypeParameters()[0];
|
final Type t = getClass().getTypeParameters()[0];
|
||||||
Assert.assertTrue(TypeUtils.equals(t, TypeUtils.wrap(t).getType()));
|
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;
|
public Iterable<? extends Map<Integer, ? extends Collection<?>>> iterable;
|
||||||
|
|
Loading…
Reference in New Issue