felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r1772345 - in /felix/trunk/converter/converter/src: main/java/org/osgi/util/converter/Converting.java test/java/org/apache/felix/converter/impl/ConverterTest.java
Date Fri, 02 Dec 2016 13:33:32 GMT
Author: davidb
Date: Fri Dec  2 13:33:32 2016
New Revision: 1772345

URL: http://svn.apache.org/viewvc?rev=1772345&view=rev
Log:
Felix Converter - add generics to Converting.to(Type)

Modified:
    felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java
    felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java

Modified: felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java?rev=1772345&r1=1772344&r2=1772345&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java
(original)
+++ felix/trunk/converter/converter/src/main/java/org/osgi/util/converter/Converting.java
Fri Dec  2 13:33:32 2016
@@ -105,7 +105,7 @@ public interface Converting {
 	 *            to.
 	 * @return The converted object.
 	 */
-	Object to(Type type);
+	<T> T to(Type type);
 
 	/**
 	 * Specify the target object type as a {@link TypeReference}. If the target

Modified: felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java?rev=1772345&r1=1772344&r2=1772345&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
(original)
+++ felix/trunk/converter/converter/src/test/java/org/apache/felix/converter/impl/ConverterTest.java
Fri Dec  2 13:33:32 2016
@@ -16,6 +16,7 @@
  */
 package org.apache.felix.converter.impl;
 
+import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.URL;
@@ -142,6 +143,13 @@ public class ConverterTest {
     }
 
     @Test
+    public void testToReflectType() {
+        Type t = TestEnum.class;
+        TestEnum e = converter.convert("X").to(t);
+        assertEquals(TestEnum.X, e);
+    }
+
+    @Test
     public void testIdentialTarget() {
         Object o = new Object();
         assertSame(o, converter.convert(o).to(Object.class));



Mime
View raw message