T - The type of the objects to count.public class ObjectCounting<T>
extends java.lang.Object
AtomicLong but object-specific.| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger
The logger for information on object counting.
|
protected java.util.Map<T,java.lang.Long> |
objectCount
The map managing the objects and their counts.
|
| Constructor and Description |
|---|
ObjectCounting()
Creates a new instance for object counting using a logger for this class
(ObjectCounting, not a subclass).
|
ObjectCounting(java.util.logging.Logger logger)
Creates a new instance for object counting using the designated logger.
|
| Modifier and Type | Method and Description |
|---|---|
long |
decreaseAndGetCount(T object)
Decreases and gets the count for the designated object.
|
long |
getCount(T object)
Returns the current count for the designated object.
|
long |
increaseAndGetCount(T object)
Increases and gets the count for the designated object.
|
boolean |
isEmpty()
Gets whether this object counting has at least one count for an arbitrary
object.
|
protected final java.util.Map<T,java.lang.Long> objectCount
protected final java.util.logging.Logger logger
public ObjectCounting()
public ObjectCounting(java.util.logging.Logger logger)
logger - The logger for information on object counting.public boolean isEmpty()
public long getCount(T object)
object - The object for which to get the count.public long increaseAndGetCount(T object)
object - The object for which to increase and get the count.public long decreaseAndGetCount(T object)
object - The object for which to decrease and get the count.