Class Incrementor


  • @Deprecated
    public class Incrementor
    extends Object
    Deprecated.
    Utility that increments a counter until a maximum is reached, at which point, the instance will by default throw a 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.
    Since:
    3.0
    • Constructor Detail

      • Incrementor

        public Incrementor()
        Deprecated.
        Default constructor. For the new instance to be useful, the maximal count must be set by calling setMaximalCount.
      • Incrementor

        public Incrementor​(int max)
        Deprecated.
        Defines a maximal count.
        Parameters:
        max - Maximal count.
    • Method Detail

      • setMaximalCount

        public void setMaximalCount​(int max)
        Deprecated.
        Sets the upper limit for the counter. This does not automatically reset the current count to zero (see resetCount()).
        Parameters:
        max - Upper limit of the counter.
      • getMaximalCount

        public int getMaximalCount()
        Deprecated.
        Gets the upper limit of the counter.
        Returns:
        the counter upper limit.
      • getCount

        public int getCount()
        Deprecated.
        Gets the current count.
        Returns:
        the current count.
      • canIncrement

        public boolean canIncrement()
        Deprecated.
        Checks whether a single increment is allowed.
        Returns:
        false if the next call to incrementCount will trigger a MaxCountExceededException, true otherwise.
      • incrementCount

        public void incrementCount()
                            throws MaxCountExceededException
        Deprecated.
        Adds one to the current iteration count. At counter exhaustion, this method will call the trigger method of the callback object passed to the constructor. If not explictly set, a default callback is used that will throw a MaxCountExceededException.
        Throws:
        MaxCountExceededException - at counter exhaustion, unless a custom callback has been set at construction.
      • resetCount

        public void resetCount()
        Deprecated.
        Resets the counter to 0.