- java.lang.Object
-
- com.pervasive.datarush.monitoring.StatisticsMap
-
- All Implemented Interfaces:
Serializable
public final class StatisticsMap extends Object implements Serializable
Utility that provides a mapping fromStatisticDefinition
toStatisticSupplier
. This map is backed by aLinkedHashMap
so that insertion order is preserved. As values are added to the map, we check that the supplier is of an appropriate type so that on read we then get a type-safe lookup.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StatisticsMap()
Create an empty map.StatisticsMap(List<RuntimeStatistic<?>> entries)
Creates a map consisting of the specified entries
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<RuntimeStatistic<?>>
entries()
Returns the list of statistic pairsStatisticsMap
finalSnapshot()
Returns a map of all the statistics in this map, converting to final snapshots.<T extends StatisticSupplier>
Tget(StatisticDefinition<T> definition)
Returns the value corresponding to the given definitionSet<StatisticDefinition<?>>
keys()
Returns the set of keys.<T extends StatisticSupplier>
voidput(RuntimeStatistic<T> statistic)
Type-safe put that adds a pair of statistic and definitionvoid
put(StatisticDefinition<?> definition, StatisticSupplier supplier)
Adds a value to the map.int
size()
Returns the number of entries in the map
-
-
-
Constructor Detail
-
StatisticsMap
public StatisticsMap()
Create an empty map.
-
StatisticsMap
public StatisticsMap(List<RuntimeStatistic<?>> entries)
Creates a map consisting of the specified entries- Parameters:
entries
- the list of entries
-
-
Method Detail
-
put
public <T extends StatisticSupplier> void put(RuntimeStatistic<T> statistic)
Type-safe put that adds a pair of statistic and definition- Type Parameters:
T
- the type of supplier- Parameters:
statistic
- the statistic to add
-
put
public void put(StatisticDefinition<?> definition, StatisticSupplier supplier)
Adds a value to the map.- Parameters:
definition
- the definition.supplier
- the supplier- Throws:
ClassCastException
- If the supplier is not of a type appropriate for the definition.
-
get
public <T extends StatisticSupplier> T get(StatisticDefinition<T> definition)
Returns the value corresponding to the given definition- Type Parameters:
T
- the type of supplier that corresponds to the definition.- Parameters:
definition
- the definition- Returns:
- the value. will never be null but may be "unavailable"
-
keys
public Set<StatisticDefinition<?>> keys()
Returns the set of keys. This will be returned in the order in which the values were added to the map.- Returns:
- the set of keys
-
entries
public List<RuntimeStatistic<?>> entries()
Returns the list of statistic pairs- Returns:
- the entries in the map
-
size
public int size()
Returns the number of entries in the map- Returns:
- the number of entries in the map
-
finalSnapshot
public StatisticsMap finalSnapshot()
Returns a map of all the statistics in this map, converting to final snapshots.- Returns:
- a final snapshot of this map
-
-