K
- enum typeV
- value typepublic abstract class EnumCollectable<K extends Enum<K>,V> extends Object implements Collectable<V>, Propertied
Collectable
storing values for enum constants. Headers are derived
from enum constants' names.Constructor and Description |
---|
EnumCollectable(Class<K> enumType,
String headersSuffix)
Constructs a new
EnumCollectable using all enum constants in
given type. |
EnumCollectable(Set<K> usedConstants,
String headersSuffix)
Constructs a new
AbstractEnumCollectable using all enum constants
in given type. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all data stored in this
Collectable , i.e. |
Set<K> |
getUsedConstants()
Returns the constants used in this collectable.
|
V |
getValue(Object enumConstant)
Returns the value mapped to the given
enumConstant . |
Iterable<String> |
obtainHeaders()
Obtains headers.
|
protected V |
obtainInitialValue() |
Collection<V> |
obtainValues()
Obtains values.
|
Properties |
properties() |
V |
putValue(K enumConstant,
V value)
Associates given enum constant with the given value.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createWriter, toMap
public EnumCollectable(Class<K> enumType, String headersSuffix)
EnumCollectable
using all enum constants in
given type.enumType
- the used enum typeheadersSuffix
- suffix applied to each header following the enum constant's
namepublic EnumCollectable(Set<K> usedConstants, String headersSuffix)
AbstractEnumCollectable
using all enum constants
in given type.usedConstants
- the set of enum constants to be used in this
Collectable
headersSuffix
- suffix applied to each header following the enum constant's
namepublic final V getValue(Object enumConstant)
enumConstant
.enumConstant
- the enum constant to return the value forenumConstant
public final V putValue(K enumConstant, V value)
enumConstant
- the enum constantvalue
- the value to associate with the constantenumConstant
protected V obtainInitialValue()
data
is to be filled when calling clear()
,
default is null
public Set<K> getUsedConstants()
public void clear()
Collectable
, i.e. the values for
every enum constant will be null
.clear
in interface Collectable<V>
public Iterable<String> obtainHeaders()
Collectable
Collectable.obtainValues()
.obtainHeaders
in interface Collectable<V>
public Collection<V> obtainValues()
Collectable
Collectable.obtainHeaders()
. Can be written
as a row into a CSV file.obtainValues
in interface Collectable<V>
public Properties properties()
properties
in interface Propertied