class AttemptBoundedExponentialBackOff implements BackOff {

  @Override
  public long nextBackOffMillis() {
    if (currentAttempt >= maximumNumberOfAttempts) {
      return BackOff.STOP;
    }
    double currentIntervalMillis = initialIntervalMillis
        * Math.pow(DEFAULT_MULTIPLIER, currentAttempt - 1);
    double randomOffset = (Math.random() * 2 - 1)
        * DEFAULT_RANDOMIZATION_FACTOR * currentIntervalMillis;
    currentAttempt += 1;
    return Math.round(currentIntervalMillis + randomOffset);
  }

  public  AttemptBoundedExponentialBackOff(int maximumNumberOfAttempts, long initialIntervalMillis);

}