Skip to content

Commit

Permalink
Improved: Rewrite ‘ComponentConfig#getAllEntityResourceInfos’
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@1862224 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 27, 2019
1 parent c28820e commit 84468dd
Showing 1 changed file with 13 additions and 17 deletions.
Expand Up @@ -93,23 +93,19 @@ public static List<EntityResourceInfo> getAllEntityResourceInfos(String type) {
return getAllEntityResourceInfos(type, null); return getAllEntityResourceInfos(type, null);
} }


public static List<EntityResourceInfo> getAllEntityResourceInfos(String type, String componentName) { /**
List<EntityResourceInfo> entityInfos = new ArrayList<>(); * Provides the list of all the entity resource information matching a type.
for (ComponentConfig cc : getAllComponents()) { *
if (componentName == null || componentName.equals(cc.getComponentName())) { * @param type the service resource type to match
List<EntityResourceInfo> ccEntityInfoList = cc.getEntityResourceInfos(); * @param name the name of the component to match
if (UtilValidate.isEmpty(type)) { * @return a list of entity resource information
entityInfos.addAll(ccEntityInfoList); */
} else { public static List<EntityResourceInfo> getAllEntityResourceInfos(String type, String name) {
for (EntityResourceInfo entityResourceInfo : ccEntityInfoList) { return getAllComponents().stream()
if (type.equals(entityResourceInfo.type)) { .filter(cc -> name == null || name.equals(cc.getComponentName()))
entityInfos.add(entityResourceInfo); .flatMap(cc -> cc.getEntityResourceInfos().stream())
} .filter(eri -> UtilValidate.isEmpty(type) || type.equals(eri.type))
} .collect(Collectors.toList());
}
}
}
return entityInfos;
} }


/** /**
Expand Down

0 comments on commit 84468dd

Please sign in to comment.