You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2012/03/15 23:06:02 UTC

svn commit: r1301233 - /commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/TextToByteConverter.java

Author: mbenson
Date: Thu Mar 15 22:06:02 2012
New Revision: 1301233

URL: http://svn.apache.org/viewvc?rev=1301233&view=rev
Log:
java 5isms; use of lang3 ArrayUtils; some class comparison safety using .equals instead of ==

Modified:
    commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/TextToByteConverter.java

Modified: commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/TextToByteConverter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/TextToByteConverter.java?rev=1301233&r1=1301232&r2=1301233&view=diff
==============================================================================
--- commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/TextToByteConverter.java (original)
+++ commons/sandbox/flatfile/trunk/src/main/java/org/apache/commons/flatfile/morph/TextToByteConverter.java Thu Mar 15 22:06:02 2012
@@ -16,10 +16,10 @@
  */
 package org.apache.commons.flatfile.morph;
 
-import java.util.Arrays;
-import java.util.HashSet;
 import java.util.Locale;
 
+import org.apache.commons.lang3.ArrayUtils;
+
 import net.sf.morph.Defaults;
 import net.sf.morph.transform.DecoratedConverter;
 import net.sf.morph.transform.transformers.BaseTransformer;
@@ -36,8 +36,8 @@ public class TextToByteConverter extends
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
-    protected Object convertImpl(Class destinationClass, Object source,
+    @Override
+    protected Object convertImpl(@SuppressWarnings("rawtypes") Class destinationClass, Object source,
             Locale locale) throws Exception {
         if (isByte(destinationClass)) {
             byte[] b = (byte[]) getTextConverter().convert(byte[].class,
@@ -52,36 +52,32 @@ public class TextToByteConverter extends
     /**
      * {@inheritDoc}
      */
+    @Override
     protected Class<?>[] getDestinationClassesImpl() throws Exception {
-        HashSet<Class<?>> s = new HashSet<Class<?>>();
-        s.addAll(Arrays.asList((Class<?>[]) getTextConverter().getDestinationClasses()));
-        s.add(byte.class);
-        s.add(Byte.class);
-        return s.toArray(new Class[s.size()]);
+        return ArrayUtils.addAll(getTextConverter().getDestinationClasses(),
+            byte.class, Byte.class);
     }
 
     /**
      * {@inheritDoc}
      */
+    @Override
     protected Class<?>[] getSourceClassesImpl() throws Exception {
-        HashSet<Class<?>> s = new HashSet<Class<?>>();
-        s.addAll(Arrays.asList((Class<?>[]) getTextConverter().getSourceClasses()));
-        s.add(byte.class);
-        s.add(Byte.class);
-        return s.toArray(new Class[s.size()]);
+        return ArrayUtils.addAll(getTextConverter().getSourceClasses(),
+            byte.class, Byte.class);
     }
 
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
-    protected boolean isTransformableImpl(Class destinationType,
-            Class sourceType) throws Exception {
+    @Override
+    protected boolean isTransformableImpl(@SuppressWarnings("rawtypes") Class destinationType,
+            @SuppressWarnings("rawtypes") Class sourceType) throws Exception {
         DecoratedConverter cnv = getTextConverter();
-        return (isByte(sourceType) && ContainerUtils.contains(cnv
-                .getDestinationClasses(), destinationType))
-                || (isByte(destinationType) && ContainerUtils.contains(cnv
-                        .getSourceClasses(), sourceType));
+        return (isByte(sourceType) && ContainerUtils.contains(
+            cnv.getDestinationClasses(), destinationType))
+            || (isByte(destinationType) && ContainerUtils.contains(
+                cnv.getSourceClasses(), sourceType));
     }
 
     /**
@@ -90,7 +86,7 @@ public class TextToByteConverter extends
      * @return boolean
      */
     private boolean isByte(Class<?> c) {
-        return c == byte.class || c == Byte.class;
+        return byte.class.equals(c) || Byte.class.equals(c);
     }
 
     /**