IntegerSequence.Incrementor
instead.@Deprecated public class Incrementor extends Object
MaxCountExceededException
.
However, the user is able to override this behaviour by defining a
custom callback
, in order to e.g.
select which exception must be thrown.Modifier and Type | Class and Description |
---|---|
static interface |
Incrementor.MaxCountExceededCallback
Deprecated.
Defines a method to be called at counter exhaustion.
|
Constructor and Description |
---|
Incrementor()
Deprecated.
Default constructor.
|
Incrementor(int max)
Deprecated.
Defines a maximal count.
|
Incrementor(int max,
Incrementor.MaxCountExceededCallback cb)
Deprecated.
Defines a maximal count and a callback method to be triggered at
counter exhaustion.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canIncrement()
Deprecated.
Checks whether a single increment is allowed.
|
int |
getCount()
Deprecated.
Gets the current count.
|
int |
getMaximalCount()
Deprecated.
Gets the upper limit of the counter.
|
void |
incrementCount()
Deprecated.
Adds one to the current iteration count.
|
void |
incrementCount(int value)
Deprecated.
Performs multiple increments.
|
void |
resetCount()
Deprecated.
Resets the counter to 0.
|
void |
setMaximalCount(int max)
Deprecated.
Sets the upper limit for the counter.
|
static Incrementor |
wrap(IntegerSequence.Incrementor incrementor)
Deprecated.
Create an instance that delegates everything to a
IntegerSequence.Incrementor . |
public Incrementor()
setMaximalCount
.public Incrementor(int max)
max
- Maximal count.public Incrementor(int max, Incrementor.MaxCountExceededCallback cb) throws NullArgumentException
max
- Maximal count.cb
- Function to be called when the maximal count has been reached.NullArgumentException
- if cb
is null
public void setMaximalCount(int max)
resetCount()
).max
- Upper limit of the counter.public int getMaximalCount()
public int getCount()
public boolean canIncrement()
false
if the next call to incrementCount
will trigger a MaxCountExceededException
,
true
otherwise.public void incrementCount(int value) throws MaxCountExceededException
incrementCount
method).value
- Number of increments.MaxCountExceededException
- at counter exhaustion.public void incrementCount() throws MaxCountExceededException
trigger
method of the
callback object passed to the
constructor
.
If not explictly set, a default callback is used that will throw
a MaxCountExceededException
.MaxCountExceededException
- at counter exhaustion, unless a
custom callback
has been set at
construction.public void resetCount()
public static Incrementor wrap(IntegerSequence.Incrementor incrementor)
IntegerSequence.Incrementor
.
This factory method is intended only as a temporary hack for internal use in
Apache Commons Math 3.X series, when Incrementor
is required in
interface (as a return value or in protected fields). It should not
be used in other cases. The IntegerSequence.Incrementor
class should
be used instead of Incrementor
.
All methods are mirrored to the underlying IntegerSequence.Incrementor
,
as long as neither setMaximalCount(int)
nor resetCount()
are called.
If one of these two methods is called, the created instance becomes independent
of the IntegerSequence.Incrementor
used at creation. The rationale is that
IntegerSequence.Incrementor
cannot change their maximal count and cannot be reset.
incrementor
- wrapped IntegerSequence.Incrementor
IntegerSequence.Incrementor
Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.