Skip to content

Commit

Permalink
Improved: Rewrite ‘ComponentConfig#getAllServiceResourceInfos’
Browse files Browse the repository at this point in the history
(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 554cad0
Showing 1 changed file with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,17 @@ public static List<KeystoreInfo> getAllKeystoreInfos() {
.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() {
Expand Down

0 comments on commit 554cad0

Please sign in to comment.