Skip to content

Commit

Permalink
Improved: Rewrite ‘ComponentConfig#getAllClasspathInfos’
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@1862215 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 27, 2019
1 parent be99f5a commit ecadb1a
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,15 @@ public static Boolean componentExists(String componentName) {
return componentConfigCache.fromGlobalName(componentName) != null;
}

/**
* Provides the list of all the classpath information available in components.
*
* @return a list of classpath information
*/
public static List<ClasspathInfo> getAllClasspathInfos() {
return getAllClasspathInfos(null);
}

public static List<ClasspathInfo> getAllClasspathInfos(String componentName) {
List<ClasspathInfo> classpaths = new ArrayList<>();
for (ComponentConfig cc : getAllComponents()) {
if (componentName == null || componentName.equals(cc.getComponentName())) {
classpaths.addAll(cc.getClasspathInfos());
}
}
return classpaths;
return getAllComponents().stream()
.flatMap(cc -> cc.getClasspathInfos().stream())
.collect(Collectors.toList());
}

public static Collection<ComponentConfig> getAllComponents() {
Expand Down

0 comments on commit ecadb1a

Please sign in to comment.