Class StaticCounter

java.lang.Object
java.util.AbstractMap
java.util.HashMap
overit.geocall.util.StaticCounter
All Implemented Interfaces:
Serializable, Cloneable, Map

public class StaticCounter extends HashMap
This class is an utility to create a set of counters. Using the static method 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:
  • Field Details

    • _counters

      protected static HashMap _counters
  • Constructor Details

    • StaticCounter

      public StaticCounter()
  • Method Details

    • getCounter

      public static StaticCounter getCounter(String name)
      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 StaticCounter corresponding to this name.
    • count

      public long count(Object counterparam)
      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

      public void reset(Object counterparam)
      Method to reset a specific value of a counter.
      Parameters:
      counterparam - The key of the value of the counter to reset.