/** * Creates a new instance with a given increment. * The counter is reset to the initial value. * * @param step Increment. * @return a new instance. */ public Incrementor withIncrement(int step) { if (step == 0) { throw new ZeroException(); } return new Incrementor(this.init, this.maximalCount, step, this.maxCountCallback); }
/** * Creates a new instance with a given increment. * The counter is reset to the initial value. * * @param step Increment. * @return a new instance. */ public Incrementor withIncrement(int step) { if (step == 0) { throw new ZeroException(); } return new Incrementor(this.init, this.maximalCount, step, this.maxCountCallback); }
/** * Creates a new instance with a given maximal count. * The counter is reset to the initial value. * * @param max Maximal count. * @return a new instance. */ public Incrementor withMaximalCount(int max) { return new Incrementor(this.init, max, this.increment, this.maxCountCallback); }
/** * Creates a new instance with a given maximal count. * The counter is reset to the initial value. * * @param max Maximal count. * @return a new instance. */ public Incrementor withMaximalCount(int max) { return new Incrementor(this.init, max, this.increment, this.maxCountCallback); }
/** * Creates a new instance with a given callback. * The counter is reset to the initial value. * * @param cb Callback to be called at counter exhaustion. * @return a new instance. */ public Incrementor withCallback(MaxCountExceededCallback cb) { return new Incrementor(this.init, this.maximalCount, this.increment, cb); }
/** * Creates a new instance with a given initial value. * The counter is reset to the initial value. * * @param start Initial value of the counter. * @return a new instance. */ public Incrementor withStart(int start) { return new Incrementor(start, this.maximalCount, this.increment, this.maxCountCallback); }
/** * Creates a new instance with a given initial value. * The counter is reset to the initial value. * * @param start Initial value of the counter. * @return a new instance. */ public Incrementor withStart(int start) { return new Incrementor(start, this.maximalCount, this.increment, this.maxCountCallback); }
/** * Factory method that creates a default instance. * The initial and maximal values are set to 0. * For the new instance to be useful, the maximal count must be set * by calling {@link #withMaximalCount(int) withMaximalCount}. * * @return an new instance. */ public static Incrementor create() { return new Incrementor(0, 0, 1, CALLBACK); }
/** * Factory method that creates a default instance. * The initial and maximal values are set to 0. * For the new instance to be useful, the maximal count must be set * by calling {@link #withMaximalCount(int) withMaximalCount}. * * @return an new instance. */ public static Incrementor create() { return new Incrementor(0, 0, 1, CALLBACK); }
/** * Creates a new instance with a given callback. * The counter is reset to the initial value. * * @param cb Callback to be called at counter exhaustion. * @return a new instance. */ public Incrementor withCallback(MaxCountExceededCallback cb) { return new Incrementor(this.init, this.maximalCount, this.increment, cb); }
/** * Creates a new instance with a given increment. * The counter is reset to the initial value. * * @param step Increment. * @return a new instance. */ public Incrementor withIncrement(int step) { if (step == 0) { throw new ZeroException(); } return new Incrementor(this.init, this.maximalCount, step, this.maxCountCallback); }
/** * Creates a new instance with a given maximal count. * The counter is reset to the initial value. * * @param max Maximal count. * @return a new instance. */ public Incrementor withMaximalCount(int max) { return new Incrementor(this.init, max, this.increment, this.maxCountCallback); }
/** * Factory method that creates a default instance. * The initial and maximal values are set to 0. * For the new instance to be useful, the maximal count must be set * by calling {@link #withMaximalCount(int) withMaximalCount}. * * @return an new instance. */ public static Incrementor create() { return new Incrementor(0, 0, 1, CALLBACK); }
/** * Creates a new instance with a given callback. * The counter is reset to the initial value. * * @param cb Callback to be called at counter exhaustion. * @return a new instance. */ public Incrementor withCallback(MaxCountExceededCallback cb) { return new Incrementor(this.init, this.maximalCount, this.increment, cb); }
/** * Creates a new instance with a given initial value. * The counter is reset to the initial value. * * @param start Initial value of the counter. * @return a new instance. */ public Incrementor withStart(int start) { return new Incrementor(start, this.maximalCount, this.increment, this.maxCountCallback); }