Improved: Rewrite ‘ComponentConfig#getAllWebappResourceInfos’

(OFBIZ-11101)

It now has a stream based implementation.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862220 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mathieu Lirzin
2019-06-27 14:26:12 +00:00
parent ba54e32071
commit 6e0432014f
@@ -149,18 +149,15 @@ public final class ComponentConfig {
.collect(Collectors.toList());
}
/**
* Provides the list of all the web-app information in components
*
* @return a list of web-app information
*/
public static List<WebappInfo> getAllWebappResourceInfos() {
return getAllWebappResourceInfos(null);
}
public static List<WebappInfo> getAllWebappResourceInfos(String componentName) {
List<WebappInfo> webappInfos = new ArrayList<>();
for (ComponentConfig cc : getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
webappInfos.addAll(cc.getWebappInfos());
}
}
return webappInfos;
return getAllComponents().stream()
.flatMap(cc -> cc.getWebappInfos().stream())
.collect(Collectors.toList());
}
public static ComponentConfig getComponentConfig(String globalName) throws ComponentException {