svn commit: r1862218 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

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

svn commit: r1862218 - /ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

mthl
Author: mthl
Date: Thu Jun 27 14:24:01 2019
New Revision: 1862218

URL: http://svn.apache.org/viewvc?rev=1862218&view=rev
Log:
Improved: Rewrite ‘ComponentConfig#getAllServiceResourceInfos’
(OFBIZ-11101)

It now has a stream based implementation.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java

Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java?rev=1862218&r1=1862217&r2=1862218&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java Thu Jun 27 14:24:01 2019
@@ -123,27 +123,17 @@ public final class ComponentConfig {
                 .collect(Collectors.toList());
     }
 
+    /**
+     * Provides the list of all the service resource information matching a type.
+     *
+     * @param type  the service resource type to match
+     * @return a list of service resource information
+     */
     public static List<ServiceResourceInfo> getAllServiceResourceInfos(String type) {
-        return getAllServiceResourceInfos(type, null);
-    }
-
-    public static List<ServiceResourceInfo> getAllServiceResourceInfos(String type, String componentName) {
-        List<ServiceResourceInfo> serviceInfos = new ArrayList<>();
-        for (ComponentConfig cc : getAllComponents()) {
-            if (componentName == null || componentName.equals(cc.getComponentName())) {
-                List<ServiceResourceInfo> ccServiceInfoList = cc.getServiceResourceInfos();
-                if (UtilValidate.isEmpty(type)) {
-                    serviceInfos.addAll(ccServiceInfoList);
-                } else {
-                    for (ServiceResourceInfo serviceResourceInfo : ccServiceInfoList) {
-                        if (type.equals(serviceResourceInfo.type)) {
-                            serviceInfos.add(serviceResourceInfo);
-                        }
-                    }
-                }
-            }
-        }
-        return serviceInfos;
+        return getAllComponents().stream()
+                .flatMap(cc -> cc.getServiceResourceInfos().stream())
+                .filter(sri -> UtilValidate.isEmpty(type) || type.equals(sri.type))
+                .collect(Collectors.toList());
     }
 
     public static List<TestSuiteInfo> getAllTestSuiteInfos() {