protected static void await(final CompletionStage<?> wait1, final CompletionStage<?> ... moreWait) { ListUtils.listOf(wait1, moreWait).forEach(stage -> stage.toCompletableFuture().join()); } }
CategoryTreeImpl(final List<Category> roots, final List<Category> allAsFlatList, final Map<LocaleSlugPair, Category> categoriesByLocaleAndSlug, final Map<String, Category> categoriesById) { this.roots = immutableCopyOf(roots); this.allAsFlatList = immutableCopyOf(allAsFlatList); this.categoriesByLocaleAndSlug = immutableCopyOf(categoriesByLocaleAndSlug); this.categoriesById = immutableCopyOf(categoriesById); }
/** * Tries to access the first element of the result list. * Use case: query by slug which should contain zero or one element in the result list. * @return the first value or absent */ public Optional<T> head() { return ListUtils.headOption(getResults()); }
public static String toString(final Category category) { final List<String> pathInTreeIds = category.getPathInTree().stream().map(Category::getId).collect(toList()); return new ToStringBuilder(category, Base.TO_STRING_STYLE). append("id", category.getId()). append("version", category.getVersion()). append("createdAt", category.getCreatedAt()). append("lastModifiedAt", category.getLastModifiedAt()). append("name", category.getName()). append("slug", category.getSlug()). append("description", category.getDescription()). append("ancestors", join(category.getAncestors())). append("parent", category.getParent()). append("orderHint", category.getOrderHint()). append("children", category.getChildren()). append("pathInTree", join(pathInTreeIds)).toString(); } }
private static List<Category> categoriesOrganizedAsTree(List<Category> allCategoriesAsFlatListWithoutChildrenSettings) { final List<Category> categoriesOrganizedInTrees; if (allCategoriesAsFlatListWithoutChildrenSettings == null) { categoriesOrganizedInTrees = Collections.emptyList(); LOGGER.warn(() -> "null passed for categories."); } else if (allCategoriesAsFlatListWithoutChildrenSettings.size() == 0) { categoriesOrganizedInTrees = Collections.emptyList(); } else { final Pair<List<Category>, List<Category>> partition = partition(allCategoriesAsFlatListWithoutChildrenSettings, new CategoryHasParentPredicate()); final List<Category> rootCategories = partition.getLeft(); final List<Category> categoriesWithoutParents = partition.getRight(); final Multimap<String, Category> categoriesByParentId = buildParentMultiMap(rootCategories); categoriesOrganizedInTrees = buildTreeRecursive(Optional.<Category>empty(), categoriesWithoutParents, new ArrayList<>(), categoriesByParentId); } return categoriesOrganizedInTrees; }
public static String toString(final Category category) { final List<String> pathInTreeIds = category.getPathInTree().stream().map(Category::getId).collect(toList()); return new ToStringBuilder(category). append("id", category.getId()). append("version", category.getVersion()). append("createdAt", category.getCreatedAt()). append("lastModifiedAt", category.getLastModifiedAt()). append("name", category.getName()). append("slug", category.getSlug()). append("description", category.getDescription()). append("ancestors", join(category.getAncestors())). append("parent", category.getParent()). append("orderHint", category.getOrderHint()). append("children", category.getChildren()). append("pathInTree", join(pathInTreeIds)).toString(); } }
private static List<Category> categoriesOrganizedAsTree(List<Category> allCategoriesAsFlatListWithoutChildrenSettings) { final List<Category> categoriesOrganizedInTrees; if (allCategoriesAsFlatListWithoutChildrenSettings == null) { categoriesOrganizedInTrees = Collections.emptyList(); LOGGER.warn(() -> "null passed for categories."); } else if (allCategoriesAsFlatListWithoutChildrenSettings.size() == 0) { categoriesOrganizedInTrees = Collections.emptyList(); } else { final Pair<List<Category>, List<Category>> partition = partition(allCategoriesAsFlatListWithoutChildrenSettings, new CategoryHasParentPredicate()); final List<Category> rootCategories = partition.getLeft(); final List<Category> categoriesWithoutParents = partition.getRight(); final Multimap<String, Category> categoriesByParentId = buildParentMultiMap(rootCategories); categoriesOrganizedInTrees = buildTreeRecursive(Optional.<Category>empty(), categoriesWithoutParents, new ArrayList<>(), categoriesByParentId); } return categoriesOrganizedInTrees; }
public void setProductId(final String id) { final List<ProductData> currentAsList = Optional.ofNullable(current).map(c -> Collections.singletonList(c)).orElse(Collections.emptyList()); ListUtils.listOf(currentAsList, staged).stream() .filter(x -> x instanceof ProductDataImpl) .forEach(x -> ((ProductDataImpl)x).setProductId(id)); } }
CategoryTreeImpl(final List<Category> roots, final List<Category> allAsFlatList, final Map<LocalizedStringEntry, Category> categoriesByLocaleAndSlug, final Map<String, Category> categoriesById, final Map<String, List<Category>> childrenByParentId) { this.childrenByParentId = childrenByParentId; this.roots = immutableCopyOf(roots); this.allAsFlatList = immutableCopyOf(allAsFlatList); this.categoriesByLocaleAndSlug = immutableCopyOf(categoriesByLocaleAndSlug); this.categoriesById = immutableCopyOf(categoriesById); }
public static String toString(final Category category) { final List<String> pathInTreeIds = category.getPathInTree().stream().map(Category::getId).collect(toList()); return new ToStringBuilder(category). append("id", category.getId()). append("version", category.getVersion()). append("createdAt", category.getCreatedAt()). append("lastModifiedAt", category.getLastModifiedAt()). append("name", category.getName()). append("slug", category.getSlug()). append("description", category.getDescription()). append("ancestors", join(category.getAncestors())). append("parent", category.getParent()). append("orderHint", category.getOrderHint()). append("children", category.getChildren()). append("pathInTree", join(pathInTreeIds)).toString(); } }
private static List<Category> categoriesOrganizedAsTree(List<Category> allCategoriesAsFlatListWithoutChildrenSettings) { final List<Category> categoriesOrganizedInTrees; if (allCategoriesAsFlatListWithoutChildrenSettings == null) { categoriesOrganizedInTrees = Collections.emptyList(); LOGGER.warn(() -> "null passed for categories."); } else if (allCategoriesAsFlatListWithoutChildrenSettings.size() == 0) { categoriesOrganizedInTrees = Collections.emptyList(); } else { final Pair<List<Category>, List<Category>> partition = partition(allCategoriesAsFlatListWithoutChildrenSettings, new CategoryHasParentPredicate()); final List<Category> rootCategories = partition.getLeft(); final List<Category> categoriesWithoutParents = partition.getRight(); final Multimap<String, Category> categoriesByParentId = buildParentMultiMap(rootCategories); categoriesOrganizedInTrees = buildTreeRecursive(Optional.<Category>empty(), categoriesWithoutParents, new ArrayList<>(), categoriesByParentId); } return categoriesOrganizedInTrees; }
@JsonIgnore public static LocalizedEnumAttributeType of(final LocalizedEnumValue mandatoryValue, final LocalizedEnumValue ... moreValues) { final List<LocalizedEnumValue> localizedEnumValues = listOf(mandatoryValue, moreValues); return of(localizedEnumValues); }
CategoryTreeImpl(final List<Category> roots, final List<Category> allAsFlatList, final Map<LocaleSlugPair, Category> categoriesByLocaleAndSlug, final Map<String, Category> categoriesById) { this.roots = immutableCopyOf(roots); this.allAsFlatList = immutableCopyOf(allAsFlatList); this.categoriesByLocaleAndSlug = immutableCopyOf(categoriesByLocaleAndSlug); this.categoriesById = immutableCopyOf(categoriesById); }
static String toString(final Category category) { return new ToStringBuilder(category, SdkDefaults.TO_STRING_STYLE) .append("id", category.getId()) .append("version", category.getVersion()) .append("createdAt", category.getCreatedAt()) .append("lastModifiedAt", category.getLastModifiedAt()) .append("name", category.getName()) .append("slug", category.getSlug()) .append("description", category.getDescription()) .append("ancestors", join(category.getAncestors())) .append("parent", category.getParent()) .append("orderHint", category.getOrderHint()) .toString(); }
@SafeVarargs @SuppressWarnings("varargs") public final Predicate<T> isIn(final Referenceable<R> reference, final Referenceable<R> ... moreReferences) { return isIn(listOf(reference, moreReferences)); } }
CategoryTreeImpl(final List<Category> roots, final List<Category> allAsFlatList, final Map<LocaleSlugPair, Category> categoriesByLocaleAndSlug, final Map<String, Category> categoriesById) { this.roots = immutableCopyOf(roots); this.allAsFlatList = immutableCopyOf(allAsFlatList); this.categoriesByLocaleAndSlug = immutableCopyOf(categoriesByLocaleAndSlug); this.categoriesById = immutableCopyOf(categoriesById); }
public ProductDraftBuilder plusVariants(final ProductVariantDraft variantToAdd) { return variants(ListUtils.listOf(this.variants, variantToAdd)); }
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());
public ProductDraftBuilder plusVariants(final List<ProductVariantDraft> variantsToAdd) { return variants(ListUtils.listOf(this.variants, variantsToAdd)); }
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());