svn commit: r1863495 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util: UtilGenerics.java UtilProperties.java

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

svn commit: r1863495 - in /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util: UtilGenerics.java UtilProperties.java

mthl
Author: mthl
Date: Sat Jul 20 16:27:23 2019
New Revision: 1863495

URL: http://svn.apache.org/viewvc?rev=1863495&view=rev
Log:
Improved: Remove useless ‘UtilGenerics#toMap’ overloads
(OFBIZ-11141)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java?rev=1863495&r1=1863494&r2=1863495&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilGenerics.java Sat Jul 20 16:27:23 2019
@@ -19,7 +19,6 @@
 package org.apache.ofbiz.base.util;
 
 import java.util.Collection;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -108,50 +107,4 @@ public final class UtilGenerics {
         }
         return (Map<K, V>) object;
     }
-
-    public static <K, V> Map<K, V> toMap(Class<K> keyType, Class<V> valueType, Object... data) {
-        if (data == null) {
-            return null;
-        }
-        if (data.length % 2 == 1) {
-            throw new IllegalArgumentException("You must pass an even sized array to the toMap method");
-        }
-        Map<K, V> map = new LinkedHashMap<>();
-        for (int i = 0; i < data.length;) {
-            Object key = data[i];
-            if (key != null && !(keyType.isInstance(key))) {
-                throw new IllegalArgumentException("Key(" + i + ") is not a " + keyType.getName() + ", was(" + key.getClass().getName() + ")");
-            }
-            i++;
-            Object value = data[i];
-            if (value != null && !(valueType.isInstance(value))) {
-                throw new IllegalArgumentException("Value(" + i + ") is not a " + keyType.getName() + ", was(" + key.getClass().getName() + ")");
-            }
-            i++;
-            map.put(keyType.cast(key), valueType.cast(value));
-        }
-        return map;
-    }
-
-    @SafeVarargs
-    @SuppressWarnings("hiding")
-    public static <K, Object> Map<K, Object> toMap(Class<K> keyType, Object... data) {
-        if (data == null) {
-            return null;
-        }
-        if (data.length % 2 == 1) {
-            throw new IllegalArgumentException("You must pass an even sized array to the toMap method");
-        }
-        Map<K, Object> map = new LinkedHashMap<>();
-        for (int i = 0; i < data.length;) {
-            Object key = data[i];
-            if (key != null && !(keyType.isInstance(key))) {
-                throw new IllegalArgumentException("Key(" + i + ") is not a " + keyType.getName() + ", was(" + key.getClass().getName() + ")");
-            }
-            i++;
-            Object value = data[i];
-            map.put(keyType.cast(key), value);
-        }
-        return map;
-    }
 }

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java?rev=1863495&r1=1863494&r2=1863495&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java Sat Jul 20 16:27:23 2019
@@ -682,7 +682,7 @@ public final class UtilProperties implem
     }
 
     public static String getMessageMap(String resource, String name, Locale locale, Object... context) {
-        return getMessage(resource, name, UtilGenerics.toMap(String.class, context), locale);
+        return getMessage(resource, name, UtilMisc.toMap(context), locale);
     }
 
     private static Set<String> resourceNotFoundMessagesShown = new HashSet<>();