K
- the category typeColT
- the type of stored Collectable
objects for every
categoryV
- the value type contained within the stored collectablespublic class CategoryCollectable<K,ColT extends Collectable<V>,V> extends Object implements Collectable<V>, Propertied
Collectable
that acts on a map containing categories each
pointing to a collectable. Dumps headers prefixed with the category in
order to separate data.Constructor and Description |
---|
CategoryCollectable(Map<K,ColT> collectablePerCategory)
Constructs a new
CategoryCollectable from given map. |
CategoryCollectable(Stream<K> categories,
Function<K,ColT> collectableMapper)
Constructs a new
CategoryCollectable from given categories. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears every contained collectable.
|
protected String |
createCategoryHeaderPrefix(K category)
Called when creating headers from categories and collectables.
|
Set<K> |
getCategories()
Returns the set of contained categories.
|
ColT |
getCollectable(K category)
Returns the collectable associated with the given category.
|
protected String |
getSeparator()
Separator in headers between category prefix and collectable's
header.
|
Iterable<String> |
obtainHeaders()
Obtains headers from collectables with the category's as prefix.
|
Iterable<V> |
obtainValues()
Obtains values from all collectables.
|
Properties |
properties() |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createWriter, toMap
public CategoryCollectable(Stream<K> categories, Function<K,ColT> collectableMapper)
CategoryCollectable
from given categories.categories
- the categories to construct fromcollectableMapper
- the mapper used to create a Collectable
for every
categorypublic CategoryCollectable(Map<K,ColT> collectablePerCategory)
CategoryCollectable
from given map.collectablePerCategory
- the map to construct frompublic Iterable<String> obtainHeaders()
obtainHeaders
in interface Collectable<V>
protected String createCategoryHeaderPrefix(K category)
Object.toString()
method.
Subclasses can override this to change default behavior.category
- protected String getSeparator()
public Iterable<V> obtainValues()
obtainValues
in interface Collectable<V>
public void clear()
clear
in interface Collectable<V>
public final Set<K> getCategories()
public final ColT getCollectable(K category)
category
- the categorypublic Properties properties()
properties
in interface Propertied