T - The type of elements for the Categorypublic final class CategoriesBuilder<T> extends Object
Category hierarchies:
CategoriesBuilder<Type> b = Categories.createBuilder("Root");
b.add(elementForRoot);
b.get("FirstChild").add(someElementForFirstChild);
b.get("FirstChild").add(someOtherElementForFirstChild);
b.get("SecondChild").add(ElementForSecondChild);
b.get("SecondChild").get("GrandChild").add(lastElement);
Category<Type> root = b.get();
This class essentially wraps a MutableCategory and offers
convenience functions for the initial construction of the categories,
for example, by creating the child categories on demand.| Modifier and Type | Method and Description |
|---|---|
CategoriesBuilder<T> |
add(T element)
Add the given element to the category represented by this builder.
|
CategoriesBuilder<T> |
addAll(Iterable<? extends T> elements)
Add the given elements to the category represented by this builder.
|
CategoriesBuilder<T> |
addIfUncategorized(String name,
Iterable<? extends T> candidates)
Add each of the given elements to a category with the given name
iff it is not already contained in the current
category or any of its children.
|
MutableCategory<T> |
get()
Returns the
MutableCategory that is currently being built |
CategoriesBuilder<T> |
get(String name)
Returns a builder for the sub-category with the given name.
|
CategoriesBuilder<T> |
mergeRecursively(Category<? extends T> other)
|
public CategoriesBuilder<T> add(T element)
element - The element to addpublic CategoriesBuilder<T> addAll(Iterable<? extends T> elements)
elements - The elements to addpublic CategoriesBuilder<T> get(String name)
name - The name of the sub-categorypublic CategoriesBuilder<T> mergeRecursively(Category<? extends T> other)
Category with the Category that is
currently being built. This merge will be performed recursively
for all sub-categories.other - The other Categorypublic CategoriesBuilder<T> addIfUncategorized(String name, Iterable<? extends T> candidates)
name - The category namecandidates - The candidates to add, if they are not yet
contained somewhere in the category hierarchypublic MutableCategory<T> get()
MutableCategory that is currently being builtMutableCategoryCopyright © 2018. All rights reserved.