svn commit: r1863502 - in /ofbiz/ofbiz-framework/trunk: applications/product/src/main/java/org/apache/ofbiz/product/product/ applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ framework/base/src/main/java/org/apache/ofbiz/bas...

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

svn commit: r1863502 - in /ofbiz/ofbiz-framework/trunk: applications/product/src/main/java/org/apache/ofbiz/product/product/ applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/ framework/base/src/main/java/org/apache/ofbiz/bas...

mthl
Author: mthl
Date: Sat Jul 20 16:36:12 2019
New Revision: 1863502

URL: http://svn.apache.org/viewvc?rev=1863502&view=rev
Log:
Improved: Inline ‘UtilGenerics#checkCollection(Object)’
(OFBIZ-11141)

Modified:
    ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java
    ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java
    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/UtilHttp.java
    ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java
    ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/Compare.java
    ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java
    ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java

Modified: ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductServices.java Sat Jul 20 16:36:12 2019
@@ -179,7 +179,7 @@ public class ProductServices {
         Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         Map<String, Object> result = new HashMap<>();
-        List<String> featureOrder = UtilMisc.makeListWritable(UtilGenerics.<String>checkCollection(context.get("featureOrder")));
+        List<String> featureOrder = UtilMisc.makeListWritable(UtilGenerics.cast(context.get("featureOrder")));
 
         if (UtilValidate.isEmpty(featureOrder)) {
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,

Modified: ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/workeffort/src/main/java/org/apache/ofbiz/workeffort/workeffort/WorkEffortServices.java Sat Jul 20 16:36:12 2019
@@ -520,7 +520,7 @@ public class WorkEffortServices {
             calendarType = "CAL_PERSONAL";
         }
         String partyId = (String) context.get("partyId");
-        Collection<String> partyIds = UtilGenerics.checkCollection(context.get("partyIds"));
+        Collection<String> partyIds = UtilGenerics.cast(context.get("partyIds"));
         String facilityId = (String) context.get("facilityId");
         String fixedAssetId = (String) context.get("fixedAssetId");
         String workEffortTypeId = (String) context.get("workEffortTypeId");

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=1863502&r1=1863501&r2=1863502&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:36:12 2019
@@ -32,10 +32,6 @@ public final class UtilGenerics {
         return (V) object;
     }
 
-    public static <T> Collection<T> checkCollection(Object object) {
-        return cast(object);
-    }
-
     public static <E, C extends Collection<E>> C checkCollection(Object object, Class<E> type) {
         if (object != null) {
             if (!(Collection.class.isInstance(object))) {

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java Sat Jul 20 16:36:12 2019
@@ -342,7 +342,7 @@ public final class UtilHttp {
                 paramEntry.setValue(canonicalizeParameter((String) paramEntry.getValue()));
             } else if (paramEntry.getValue() instanceof Collection<?>) {
                 List<String> newList = new LinkedList<>();
-                for (String listEntry: UtilGenerics.<String>checkCollection(paramEntry.getValue())) {
+                for (String listEntry: UtilGenerics.<Collection<String>>cast(paramEntry.getValue())) {
                     newList.add(canonicalizeParameter(listEntry));
                 }
                 paramEntry.setValue(newList);

Modified: ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java Sat Jul 20 16:36:12 2019
@@ -997,7 +997,8 @@ public final class SqlJdbcUtil {
     public static void addValue(StringBuilder buffer, ModelField field, Object value, List<EntityConditionParam> params) {
         if (value instanceof Collection<?>) {
             buffer.append("(");
-            Iterator<Object> it = UtilGenerics.checkCollection(value).iterator();
+            Collection<Object> coll = UtilGenerics.cast(value);
+            Iterator<Object> it = coll.iterator();
             while (it.hasNext()) {
                 Object thisValue = it.next();
                 addValueSingle(buffer, field, thisValue, params);

Modified: ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/Compare.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/Compare.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/Compare.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/conditional/Compare.java Sat Jul 20 16:36:12 2019
@@ -96,7 +96,7 @@ public abstract class Compare {
                 return false;
             }
             if (lValue instanceof Collection) {
-                Collection<Object> collection = UtilGenerics.checkCollection(lValue);
+                Collection<Object> collection = UtilGenerics.cast(lValue);
                 return collection.contains(rValue);
             }
             if (lValue instanceof String && rValue instanceof String) {

Modified: ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java Sat Jul 20 16:36:12 2019
@@ -100,7 +100,7 @@ public final class Iterate extends Metho
                 throw new MiniLangRuntimeException("Error with entityListIterator: " + e.getMessage(), this);
             }
         } else if (objList instanceof Collection<?>) {
-            Collection<Object> theCollection = UtilGenerics.checkCollection(objList);
+            Collection<Object> theCollection = UtilGenerics.cast(objList);
             if (theCollection.size() == 0) {
                 if (Debug.verboseOn()) {
                      Debug.logVerbose("Collection has zero entries, doing nothing: " + this, module);

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/CoreEvents.java Sat Jul 20 16:36:12 2019
@@ -18,7 +18,6 @@
  *******************************************************************************/
 package org.apache.ofbiz.webapp.event;
 
-import static org.apache.ofbiz.base.util.UtilGenerics.checkCollection;
 import static org.apache.ofbiz.base.util.UtilGenerics.checkMap;
 
 import java.io.File;
@@ -404,7 +403,7 @@ public class CoreEvents {
                     servicePathMap.put(entry.getKey(), entry.getValue());
                 }
             } else if (servicePathObject instanceof Collection<?>) {
-                Collection<?> servicePathColl = checkCollection(servicePathObject);
+                Collection<?> servicePathColl = UtilGenerics.cast(servicePathObject);
                 int count=0;
                 servicePathMap = new HashMap<>();
                 for (Object value: servicePathColl) {

Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java?rev=1863502&r1=1863501&r2=1863502&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java Sat Jul 20 16:36:12 2019
@@ -380,7 +380,7 @@ public class ModelFormField {
                     DateFormat df = UtilDateTime.toDateTimeFormat("EEE MMM dd hh:mm:ss z yyyy", timeZone, null);
                     return df.format((java.util.Date) retVal);
                 } else if (retVal instanceof Collection) {
-                    Collection<Object> col = UtilGenerics.checkCollection(retVal);
+                    Collection<Object> col = UtilGenerics.cast(retVal);
                     Iterator<Object> iter = col.iterator();
                     List<Object> newCol = new ArrayList<>(col.size());
                     while (iter.hasNext()) {