Package overit.geocall.util
Class StaticCounter
java.lang.Object
java.util.AbstractMap
java.util.HashMap
overit.geocall.util.StaticCounter
- All Implemented Interfaces:
Serializable,Cloneable,Map
This class is an utility to create a set of counters. Using the static method
Every counter can have multiple key-value combinations as it is a
This method are synchronized to limit possible use to one thread at a time.
getCounter("name") it is possible to obtain
a specific counter or create it if it does not exist.Every counter can have multiple key-value combinations as it is a
HashMap.
It is necessary to use the count(key) to increment
a value of a counter, and use reset(key) to reset
a value of a counter.This method are synchronized to limit possible use to one thread at a time.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongMethod to increment by one a specific value of a counter.static StaticCountergetCounter(String name) Method to get a specific counter.voidMethod to reset a specific value of a counter.Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Field Details
-
_counters
-
-
Constructor Details
-
StaticCounter
public StaticCounter()
-
-
Method Details
-
getCounter
Method to get a specific counter. If it does not exist, it is created and added to the list of counters.- Parameters:
name- The name of the counter to search.- Returns:
- The
StaticCountercorresponding to this name.
-
count
Method to increment by one a specific value of a counter.- Parameters:
counterparam- The key of the value of the counter to increment.- Returns:
- The value increased by one.
-
reset
Method to reset a specific value of a counter.- Parameters:
counterparam- The key of the value of the counter to reset.
-