public class ModuloCounter extends java.lang.Object implements ICounter
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_MAX_VALUE
The default largest number that can be held by the counter
|
static long |
DEFAULT_MIN_VALUE
The default smallest number that can be held by the counter
|
Constructor and Description |
---|
ModuloCounter()
Default constructor, initializes with default minimum and maximum bounds.
|
ModuloCounter(long maxValue)
Initializes counter with a specified maximum value.
|
ModuloCounter(long maxValue,
long minValue)
Initializes counter with a specified maximum value and minimum value.
|
Modifier and Type | Method and Description |
---|---|
long |
getMaxValue()
Returns the maximum value of the counter
|
long |
getMinValue()
Returns the minimum value of the counter
|
long |
getValue()
Returns the counter value
|
long |
next()
Increments the counter and returns the next value
|
void |
reset()
Resets the counter to the minimum value
|
public static final long DEFAULT_MIN_VALUE
public static final long DEFAULT_MAX_VALUE
public ModuloCounter()
public ModuloCounter(long maxValue)
maxValue
- The maximum counter value.java.lang.IllegalArgumentException
- When the maximum is less than or equal to minimum, or equal to Long.MAX_VALUEpublic ModuloCounter(long maxValue, long minValue)
maxValue
- The maximum counter value.minValue
- The minimum counter value.java.lang.IllegalArgumentException
- When the maximum is less than or equal to minimum, or equal to Long.MAX_VALUEpublic long getValue()
public long getMinValue()
getMinValue
in interface ICounter
public long getMaxValue()
getMaxValue
in interface ICounter
public long next()