commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adri...@apache.org
Subject svn commit: r932837 - in /commons/sandbox/convert/trunk/src: main/java/org/apache/commons/convert/BooleanConverters.java test/java/org/apache/commons/convert/TestBooleanConverters.java
Date Sun, 11 Apr 2010 05:44:59 GMT
Author: adrianc
Date: Sun Apr 11 05:44:59 2010
New Revision: 932837

URL: http://svn.apache.org/viewvc?rev=932837&view=rev
Log:
Eliminated two classes from BooleanConverters.java.

Modified:
    commons/sandbox/convert/trunk/src/main/java/org/apache/commons/convert/BooleanConverters.java
    commons/sandbox/convert/trunk/src/test/java/org/apache/commons/convert/TestBooleanConverters.java

Modified: commons/sandbox/convert/trunk/src/main/java/org/apache/commons/convert/BooleanConverters.java
URL: http://svn.apache.org/viewvc/commons/sandbox/convert/trunk/src/main/java/org/apache/commons/convert/BooleanConverters.java?rev=932837&r1=932836&r2=932837&view=diff
==============================================================================
--- commons/sandbox/convert/trunk/src/main/java/org/apache/commons/convert/BooleanConverters.java
(original)
+++ commons/sandbox/convert/trunk/src/main/java/org/apache/commons/convert/BooleanConverters.java
Sun Apr 11 05:44:59 2010
@@ -30,18 +30,6 @@ public class BooleanConverters implement
         }
     }
 
-    public static class BooleanToList extends GenericSingletonToList<Boolean> {
-        public BooleanToList() {
-            super(Boolean.class);
-        }
-    }
-
-    public static class BooleanToSet extends GenericSingletonToSet<Boolean> {
-        public BooleanToSet() {
-            super(Boolean.class);
-        }
-    }
-
     public static class IntegerToBoolean extends AbstractConverter<Integer, Boolean>
{
         public IntegerToBoolean() {
             super(Integer.class, Boolean.class);
@@ -64,6 +52,8 @@ public class BooleanConverters implement
 
     public void loadConverters() {
         Converters.loadContainedConverters(BooleanConverters.class);
+        Converters.registerConverter(new GenericSingletonToList<Boolean>(Boolean.class));
+        Converters.registerConverter(new GenericSingletonToSet<Boolean>(Boolean.class));
         Converters.registerConverter(new GenericToStringConverter<Boolean>(Boolean.class));
     }
 }

Modified: commons/sandbox/convert/trunk/src/test/java/org/apache/commons/convert/TestBooleanConverters.java
URL: http://svn.apache.org/viewvc/commons/sandbox/convert/trunk/src/test/java/org/apache/commons/convert/TestBooleanConverters.java?rev=932837&r1=932836&r2=932837&view=diff
==============================================================================
--- commons/sandbox/convert/trunk/src/test/java/org/apache/commons/convert/TestBooleanConverters.java
(original)
+++ commons/sandbox/convert/trunk/src/test/java/org/apache/commons/convert/TestBooleanConverters.java
Sun Apr 11 05:44:59 2010
@@ -49,11 +49,13 @@ public class TestBooleanConverters exten
     }
 
     @SuppressWarnings("unchecked")
-    public static void assertToCollection(String label, Converter<Boolean, ? extends Collection<Boolean>>
converter, Class<? extends Collection> targetClass) throws Exception {
-        assertTrue(label + " can convert", converter.canConvert(Boolean.class, targetClass
));
-        assertEquals(label + " registered", converter.getClass(), Converters.getConverter(Boolean.class,
targetClass).getClass());
-        Collection<Boolean> result = converter.convert(Boolean.TRUE);
-        assertEquals(label + " converted", Boolean.TRUE, result.toArray()[0]);
+    public static <S> void assertToCollection(String label, S source) throws Exception
{
+        Converter<S, ? extends Collection> toList = (Converter<S, ? extends Collection>)
Converters.getConverter(source.getClass(), List.class);
+        Collection<S> listResult = toList.convert(source);
+        assertEquals(label + " converted to List", source, listResult.toArray()[0]);
+        Converter<S, ? extends Collection> toSet = (Converter<S, ? extends Collection>)
Converters.getConverter(source.getClass(), Set.class);
+        Collection<S> setResult = toSet.convert(source);
+        assertEquals(label + " converted to Set", source, setResult.toArray()[0]);
     }
 
     public void testBooleanConverters() throws Exception {
@@ -63,7 +65,6 @@ public class TestBooleanConverters exten
         assertFromBoolean("BooleanToString", new GenericToStringConverter<Boolean>(Boolean.class),
"true", "false");
         assertToBoolean("IntegerToBoolean", new BooleanConverters.IntegerToBoolean(), 1,
0);
         assertToBoolean("StringToBoolean", new BooleanConverters.StringToBoolean(), "true",
"false");
-        assertToCollection("BooleanToList", new BooleanConverters.BooleanToList(), List.class);
-        assertToCollection("BooleanToSet", new BooleanConverters.BooleanToSet(), Set.class);
+        assertToCollection("BooleanToCollection", Boolean.TRUE);
     }
 }



Mime
View raw message