svn commit: r1818546 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1818546 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/

mbrohl
Author: mbrohl
Date: Mon Dec 18 10:09:55 2017
New Revision: 1818546

URL: http://svn.apache.org/viewvc?rev=1818546&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.base.conversion.
(OFBIZ-9929)

Thanks Dennis Balkir for reporting and providing the patches.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/CollectionConverters.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/Converters.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToList.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToSet.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NetConverters.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/CollectionConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/CollectionConverters.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/CollectionConverters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/CollectionConverters.java Mon Dec 18 10:09:55 2017
@@ -147,9 +147,8 @@ public class CollectionConverters implem
         public List<String> convert(String obj) throws ConversionException {
             if (obj.startsWith("[") && obj.endsWith("]")) {
                 return StringUtil.toList(obj);
-            } else {
-                return super.convert(obj);
             }
+            return super.convert(obj);
         }
     }
 
@@ -175,9 +174,8 @@ public class CollectionConverters implem
         public Set<String> convert(String obj) throws ConversionException {
             if (obj.startsWith("[") && obj.endsWith("]")) {
                 return StringUtil.toSet(obj);
-            } else {
-                return super.convert(obj);
             }
+            return super.convert(obj);
         }
     }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/Converters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/Converters.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/Converters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/Converters.java Mon Dec 18 10:09:55 2017
@@ -18,7 +18,6 @@
  *******************************************************************************/
 package org.apache.ofbiz.base.conversion;
 
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
 import java.util.HashSet;
 import java.util.Iterator;

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/DateTimeConverters.java Mon Dec 18 10:09:55 2017
@@ -683,9 +683,8 @@ public class DateTimeConverters implemen
             TimeZone tz = UtilDateTime.toTimeZone(obj);
             if (tz != null) {
                 return tz;
-            } else {
-                throw new ConversionException("Could not convert " + obj + " to TimeZone: ");
             }
+            throw new ConversionException("Could not convert " + obj + " to TimeZone: ");
         }
     }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToList.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToList.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToList.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToList.java Mon Dec 18 10:09:55 2017
@@ -27,7 +27,7 @@ public class GenericSingletonToList<T> e
     }
 
     public List<T> convert(T obj) throws ConversionException {
-        List<T> tempList = new LinkedList<T>();
+        List<T> tempList = new LinkedList<>();
         tempList.add(obj);
         return tempList;
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToSet.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToSet.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToSet.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/GenericSingletonToSet.java Mon Dec 18 10:09:55 2017
@@ -27,7 +27,7 @@ public class GenericSingletonToSet<T> ex
     }
 
     public Set<T> convert(T obj) throws ConversionException {
-        Set<T> tempSet = new HashSet<T>();
+        Set<T> tempSet = new HashSet<>();
         tempSet.add(obj);
         return tempSet;
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/MiscConverters.java Mon Dec 18 10:09:55 2017
@@ -233,9 +233,8 @@ public class MiscConverters implements C
             Locale loc = UtilMisc.parseLocale(obj);
             if (loc != null) {
                 return loc;
-            } else {
-                throw new ConversionException("Could not convert " + obj + " to Locale: ");
             }
+            throw new ConversionException("Could not convert " + obj + " to Locale: ");
         }
     }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NetConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NetConverters.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NetConverters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NetConverters.java Mon Dec 18 10:09:55 2017
@@ -50,7 +50,9 @@ public class NetConverters implements Co
 
         public String convert(InetAddress obj) throws ConversionException {
             String hostName = obj.getHostName();
-            if (hostName != null) return hostName;
+            if (hostName != null) {
+                return hostName;
+            }
             return obj.getHostAddress();
         }
     }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java?rev=1818546&r1=1818545&r2=1818546&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/conversion/NumberConverters.java Mon Dec 18 10:09:55 2017
@@ -399,57 +399,57 @@ public class NumberConverters implements
     public void loadConverters() {
         Converters.loadContainedConverters(NumberConverters.class);
 
-        Converters.registerConverter(new GenericNumberToDouble<BigDecimal>(BigDecimal.class));
-        Converters.registerConverter(new GenericNumberToDouble<BigInteger>(BigInteger.class));
-        Converters.registerConverter(new GenericNumberToDouble<Byte>(Byte.class));
-        Converters.registerConverter(new GenericNumberToDouble<Float>(Float.class));
-        Converters.registerConverter(new GenericNumberToDouble<Integer>(Integer.class));
-        Converters.registerConverter(new GenericNumberToDouble<Long>(Long.class));
-        Converters.registerConverter(new GenericNumberToDouble<Short>(Short.class));
-
-        Converters.registerConverter(new GenericNumberToFloat<BigDecimal>(BigDecimal.class));
-        Converters.registerConverter(new GenericNumberToFloat<BigInteger>(BigInteger.class));
-        Converters.registerConverter(new GenericNumberToFloat<Byte>(Byte.class));
-        Converters.registerConverter(new GenericNumberToFloat<Double>(Double.class));
-        Converters.registerConverter(new GenericNumberToFloat<Integer>(Integer.class));
-        Converters.registerConverter(new GenericNumberToFloat<Long>(Long.class));
-        Converters.registerConverter(new GenericNumberToFloat<Short>(Short.class));
-
-        Converters.registerConverter(new GenericNumberToInteger<BigDecimal>(BigDecimal.class));
-        Converters.registerConverter(new GenericNumberToInteger<BigInteger>(BigInteger.class));
-        Converters.registerConverter(new GenericNumberToInteger<Byte>(Byte.class));
-        Converters.registerConverter(new GenericNumberToInteger<Double>(Double.class));
-        Converters.registerConverter(new GenericNumberToInteger<Float>(Float.class));
-        Converters.registerConverter(new GenericNumberToInteger<Long>(Long.class));
-        Converters.registerConverter(new GenericNumberToInteger<Short>(Short.class));
-
-        Converters.registerConverter(new GenericSingletonToList<BigDecimal>(BigDecimal.class));
-        Converters.registerConverter(new GenericSingletonToList<BigInteger>(BigInteger.class));
-        Converters.registerConverter(new GenericSingletonToList<Byte>(Byte.class));
-        Converters.registerConverter(new GenericSingletonToList<Double>(Double.class));
-        Converters.registerConverter(new GenericSingletonToList<Float>(Float.class));
-        Converters.registerConverter(new GenericSingletonToList<Integer>(Integer.class));
-        Converters.registerConverter(new GenericSingletonToList<Long>(Long.class));
-        Converters.registerConverter(new GenericSingletonToList<Short>(Short.class));
-
-        Converters.registerConverter(new GenericNumberToLong<BigDecimal>(BigDecimal.class));
-        Converters.registerConverter(new GenericNumberToLong<BigInteger>(BigInteger.class));
-        Converters.registerConverter(new GenericNumberToLong<Byte>(Byte.class));
-        Converters.registerConverter(new GenericNumberToLong<Double>(Double.class));
-        Converters.registerConverter(new GenericNumberToLong<Float>(Float.class));
-        Converters.registerConverter(new GenericNumberToLong<Integer>(Integer.class));
-        Converters.registerConverter(new GenericNumberToLong<Short>(Short.class));
-
-        Converters.registerConverter(new GenericSingletonToSet<BigDecimal>(BigDecimal.class));
-        Converters.registerConverter(new GenericSingletonToSet<BigInteger>(BigInteger.class));
-        Converters.registerConverter(new GenericSingletonToSet<Byte>(Byte.class));
-        Converters.registerConverter(new GenericSingletonToSet<Double>(Double.class));
-        Converters.registerConverter(new GenericSingletonToSet<Float>(Float.class));
-        Converters.registerConverter(new GenericSingletonToSet<Integer>(Integer.class));
-        Converters.registerConverter(new GenericSingletonToSet<Long>(Long.class));
-        Converters.registerConverter(new GenericSingletonToSet<Short>(Short.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(BigDecimal.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(BigInteger.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(Byte.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(Float.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(Integer.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(Long.class));
+        Converters.registerConverter(new GenericNumberToDouble<>(Short.class));
+
+        Converters.registerConverter(new GenericNumberToFloat<>(BigDecimal.class));
+        Converters.registerConverter(new GenericNumberToFloat<>(BigInteger.class));
+        Converters.registerConverter(new GenericNumberToFloat<>(Byte.class));
+        Converters.registerConverter(new GenericNumberToFloat<>(Double.class));
+        Converters.registerConverter(new GenericNumberToFloat<>(Integer.class));
+        Converters.registerConverter(new GenericNumberToFloat<>(Long.class));
+        Converters.registerConverter(new GenericNumberToFloat<>(Short.class));
+
+        Converters.registerConverter(new GenericNumberToInteger<>(BigDecimal.class));
+        Converters.registerConverter(new GenericNumberToInteger<>(BigInteger.class));
+        Converters.registerConverter(new GenericNumberToInteger<>(Byte.class));
+        Converters.registerConverter(new GenericNumberToInteger<>(Double.class));
+        Converters.registerConverter(new GenericNumberToInteger<>(Float.class));
+        Converters.registerConverter(new GenericNumberToInteger<>(Long.class));
+        Converters.registerConverter(new GenericNumberToInteger<>(Short.class));
+
+        Converters.registerConverter(new GenericSingletonToList<>(BigDecimal.class));
+        Converters.registerConverter(new GenericSingletonToList<>(BigInteger.class));
+        Converters.registerConverter(new GenericSingletonToList<>(Byte.class));
+        Converters.registerConverter(new GenericSingletonToList<>(Double.class));
+        Converters.registerConverter(new GenericSingletonToList<>(Float.class));
+        Converters.registerConverter(new GenericSingletonToList<>(Integer.class));
+        Converters.registerConverter(new GenericSingletonToList<>(Long.class));
+        Converters.registerConverter(new GenericSingletonToList<>(Short.class));
+
+        Converters.registerConverter(new GenericNumberToLong<>(BigDecimal.class));
+        Converters.registerConverter(new GenericNumberToLong<>(BigInteger.class));
+        Converters.registerConverter(new GenericNumberToLong<>(Byte.class));
+        Converters.registerConverter(new GenericNumberToLong<>(Double.class));
+        Converters.registerConverter(new GenericNumberToLong<>(Float.class));
+        Converters.registerConverter(new GenericNumberToLong<>(Integer.class));
+        Converters.registerConverter(new GenericNumberToLong<>(Short.class));
+
+        Converters.registerConverter(new GenericSingletonToSet<>(BigDecimal.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(BigInteger.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(Byte.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(Double.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(Float.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(Integer.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(Long.class));
+        Converters.registerConverter(new GenericSingletonToSet<>(Short.class));
 
-        Converters.registerConverter(new GenericNumberToShort<Integer>(Integer.class));
-        Converters.registerConverter(new GenericNumberToShort<Long>(Long.class));
+        Converters.registerConverter(new GenericNumberToShort<>(Integer.class));
+        Converters.registerConverter(new GenericNumberToShort<>(Long.class));
     }
 }