/** * Performs multiple increments. * * @param nTimes Number of increments. * @throws MaxCountExceededException at counter exhaustion. * @throws NotStrictlyPositiveException if {@code nTimes <= 0}. * * @see #increment() */ public void increment(int nTimes) throws MaxCountExceededException { if (nTimes <= 0) { throw new NotStrictlyPositiveException(nTimes); } if (!canIncrement(0)) { maxCountCallback.trigger(maximalCount); } count += nTimes * increment; }
/** * Performs multiple increments. * * @param nTimes Number of increments. * @throws MaxCountExceededException at counter exhaustion. * @throws NotStrictlyPositiveException if {@code nTimes <= 0}. * * @see #increment() */ public void increment(int nTimes) throws MaxCountExceededException { if (nTimes <= 0) { throw new NotStrictlyPositiveException(nTimes); } if (!canIncrement(0)) { maxCountCallback.trigger(maximalCount); } count += nTimes * increment; }
/** {@inheritDoc} */ public boolean hasNext() { return canIncrement(0); }
/** * Checks whether incrementing the counter {@code nTimes} is allowed. * * @return {@code false} if calling {@link #increment()} * will trigger a {@code MaxCountExceededException}, * {@code true} otherwise. */ public boolean canIncrement() { return canIncrement(1); }
/** * Checks whether incrementing the counter {@code nTimes} is allowed. * * @return {@code false} if calling {@link #increment()} * will trigger a {@code MaxCountExceededException}, * {@code true} otherwise. */ public boolean canIncrement() { return canIncrement(1); }
/** {@inheritDoc} */ public boolean hasNext() { return canIncrement(0); }
/** * Performs multiple increments. * * @param nTimes Number of increments. * @throws MaxCountExceededException at counter exhaustion. * @throws NotStrictlyPositiveException if {@code nTimes <= 0}. * * @see #increment() */ public void increment(int nTimes) throws MaxCountExceededException { if (nTimes <= 0) { throw new NotStrictlyPositiveException(nTimes); } if (!canIncrement(0)) { maxCountCallback.trigger(maximalCount); } count += nTimes * increment; }
/** {@inheritDoc} */ public boolean hasNext() { return canIncrement(0); }
/** * Checks whether incrementing the counter {@code nTimes} is allowed. * * @return {@code false} if calling {@link #increment()} * will trigger a {@code MaxCountExceededException}, * {@code true} otherwise. */ public boolean canIncrement() { return canIncrement(1); }