Skip to content
Permalink
Browse files

Improved: Rewrite ‘ComponentConfig#getAllServiceResourceInfos’

(OFBIZ-11101)

It now has a stream based implementation.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862218 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 27, 2019
1 parent 58ed9c5 commit 554cad028956a8579f9a7c1e3f0af266e7d14c9b
Showing with 10 additions and 20 deletions.
  1. +10 −20 framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java
@@ -123,27 +123,17 @@ public static Boolean componentExists(String componentName) {
.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() {

0 comments on commit 554cad0

Please sign in to comment.
You can’t perform that action at this time.