Class UnsynchronizedLongCounter

  • All Implemented Interfaces:
    Counter, Statistic

    public class UnsynchronizedLongCounter
    extends AbstractStatistic
    implements Counter
    Class to count events in a thread-safe counter.
    Since:
    0.6.0
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) long counter
      The counter to use.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long decrement()
      Decrement the counter.
      java.lang.String formatValue()
      Get a formatted version of the value, for output.
      long getValue()
      Get the current count.
      long increment()
      Increment the counter.
      long increment​(long i)
      Increment the counter by i.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • counter

        long counter
        The counter to use.
    • Constructor Detail

      • UnsynchronizedLongCounter

        public UnsynchronizedLongCounter​(java.lang.String key)
        Constructor.
        Parameters:
        key - Key to report.
    • Method Detail

      • increment

        public long increment()
        Description copied from interface: Counter
        Increment the counter.
        Specified by:
        increment in interface Counter
        Returns:
        Current value.
      • decrement

        public long decrement()
        Description copied from interface: Counter
        Decrement the counter.
        Specified by:
        decrement in interface Counter
        Returns:
        Current value.
      • increment

        public long increment​(long i)
        Description copied from interface: Counter
        Increment the counter by i. Note: the increment may be negative!
        Specified by:
        increment in interface Counter
        Parameters:
        i - increment.
        Returns:
        Current count.
      • getValue

        public long getValue()
        Description copied from interface: Counter
        Get the current count.
        Specified by:
        getValue in interface Counter
        Returns:
        Current count.
      • formatValue

        public java.lang.String formatValue()
        Description copied from interface: Statistic
        Get a formatted version of the value, for output.
        Specified by:
        formatValue in interface Statistic
        Returns:
        Value