Skip to content


Improved: Extract ‘intersects’ predicate in a method
Browse files Browse the repository at this point in the history

The lambda expression was a bit too long, so it is preferable to
extract it in a dedicated method.

git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 10, 2019
1 parent 266e0d0 commit ddbc034
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,22 @@ private static Collection<ContainerConfig.Configuration> retrieveOfbizContainers
private static List<ContainerConfig.Configuration> filterContainersHavingMatchingLoaders(List<String> loaders,
Collection<ContainerConfig.Configuration> containerConfigs) {
.filter(containerCfg ->
UtilValidate.isEmpty(containerCfg.loaders) &&
UtilValidate.isEmpty(loaders) || -> loaders.contains(loader)))
.filter(cfg -> intersects(cfg.loaders, loaders))

* Checks if two collections have an intersection or are both empty.
* @param a the first collection which can be {@code null}
* @param b the second collection which can be {@code null}
* @return {@code true} if {@code a} and {@code b} have an intersection or are both empty.
private static boolean intersects(Collection<?> a, Collection<?> b) {
return UtilValidate.isEmpty(a) && UtilValidate.isEmpty(b)
|| !Collections.disjoint(a, b);

private static List<Container> loadContainersFromConfigurations(List<ContainerConfig.Configuration> containerConfigs,
Config config, List<StartupCommand> ofbizCommands) throws StartupException {

Expand Down

0 comments on commit ddbc034

Please sign in to comment.