private static Multimap<String, Category> buildParentMultiMap(List<Category> categoriesWithParents) { final Multimap<String, Category> categoriesByParentId = new Multimap<>(); for (final Category categoryWithParent : categoriesWithParents) { final String parentId = categoryWithParent.getParent().get().getId(); categoriesByParentId.put(parentId, categoryWithParent); } return categoriesByParentId; }
final List<Category> childrenForCategory = immutableCopyOf(buildTreeRecursive(Optional.of(child), categoriesByParent.get(child.getId()), pathInTree, categoriesByParent)); final List<Category> pathInTreeForCategory = immutableCopyOf(pathInTree); final Optional<Reference<Category>> parentForCategory = parent.map(p -> p.toReference());
final List<Category> childrenForCategory = immutableCopyOf(buildTreeRecursive(Optional.of(child), categoriesByParent.get(child.getId()), pathInTree, categoriesByParent)); final List<Category> pathInTreeForCategory = immutableCopyOf(pathInTree); final Optional<Reference<Category>> parentForCategory = parent.map(p -> p.toReference());
private static Multimap<String, Category> buildParentMultiMap(List<Category> categoriesWithParents) { final Multimap<String, Category> categoriesByParentId = new Multimap<>(); for (final Category categoryWithParent : categoriesWithParents) { final String parentId = categoryWithParent.getParent().get().getId(); categoriesByParentId.put(parentId, categoryWithParent); } return categoriesByParentId; }
final List<Category> childrenForCategory = immutableCopyOf(buildTreeRecursive(Optional.of(child), categoriesByParent.get(child.getId()), pathInTree, categoriesByParent)); final List<Category> pathInTreeForCategory = immutableCopyOf(pathInTree); final Optional<Reference<Category>> parentForCategory = parent.map(p -> p.toReference());
private static Multimap<String, Category> buildParentMultiMap(List<Category> categoriesWithParents) { final Multimap<String, Category> categoriesByParentId = new Multimap<>(); for (final Category categoryWithParent : categoriesWithParents) { final String parentId = categoryWithParent.getParent().get().getId(); categoriesByParentId.put(parentId, categoryWithParent); } return categoriesByParentId; }