commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1525724 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/reflect/TypeUtils.java test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
Date Mon, 23 Sep 2013 22:51:58 GMT
Author: mbenson
Date: Mon Sep 23 22:51:57 2013
New Revision: 1525724

URL: http://svn.apache.org/r1525724
Log:
add typesafe wrap variant for classes

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java?rev=1525724&r1=1525723&r2=1525724&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java
Mon Sep 23 22:51:57 2013
@@ -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();
 

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java?rev=1525724&r1=1525723&r2=1525724&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
Mon Sep 23 22:51:57 2013
@@ -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;



Mime
View raw message