Class JBBPIntCounter

java.lang.Object
java.lang.Number
com.igormaznitsa.jbbp.utils.JBBPIntCounter
All Implemented Interfaces:
Serializable

public final class JBBPIntCounter extends Number
The Class implements a simple thread unsafe integer counter.
Since:
1.0
See Also:
  • Constructor Details

    • JBBPIntCounter

      public JBBPIntCounter()
      The Constructor to initialize the counter by 0.
    • JBBPIntCounter

      public JBBPIntCounter(int startValue)
      The Constructor to initialize the counter by an integer value.
      Parameters:
      startValue - the start integer value for the counter
  • Method Details

    • set

      public void set(int value)
      Set the value for the counter.
      Parameters:
      value - the new value for the counter
    • inc

      public void inc()
      Increase the counter.
    • dec

      public void dec()
      Decrease the counter.
    • getAndIncrement

      public int getAndIncrement()
      Get the counter value and increment the counter after result return.
      Returns:
      the value before increment.
    • incrementAndGet

      public int incrementAndGet()
      Increment the counter and get the incremented result.
      Returns:
      the value after increment
    • getAndDecrement

      public int getAndDecrement()
      Get the counter value and decrement the counter after result return.
      Returns:
      the value before decrement
    • decrementAndGet

      public int decrementAndGet()
      Decrement the counter and return the decremented value.
      Returns:
      the decremented value
    • get

      public int get()
      Get the counter value.
      Returns:
      the current counter value
    • getAndAdd

      public int getAndAdd(int value)
      Get the current counter value and add a value after the return.
      Parameters:
      value - a value to be added to the counter
      Returns:
      the counter before addition
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number