Class Delay

    • Method Detail

      • calculate

        public abstract long calculate​(long attempt)
        Calculate a specific delay based on the attempt passed in. This method is to be implemented by the child implementations and depending on the params that were set during construction time.
        Parameters:
        attempt - the attempt to calculate the delay from.
        Returns:
        the calculate delay.
      • fixed

        public static Delay fixed​(long delay,
                                  TimeUnit unit)
        Creates a new FixedDelay.
        Parameters:
        delay - the time of the delay.
        unit - the unit of the delay.
        Returns:
        a created FixedDelay.
      • linear

        public static Delay linear​(TimeUnit unit)
        Creates a new LinearDelay with no bounds and default factor.
        Parameters:
        unit - the unit of the delay.
        Returns:
        a created LinearDelay.
      • linear

        public static Delay linear​(TimeUnit unit,
                                   long upper)
        Creates a new LinearDelay with a custom upper boundary and the default factor.
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        Returns:
        a created LinearDelay.
      • linear

        public static Delay linear​(TimeUnit unit,
                                   long upper,
                                   long lower)
        Creates a new LinearDelay with a custom boundaries and the default factor.
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        lower - the lower boundary.
        Returns:
        a created LinearDelay.
      • linear

        public static Delay linear​(TimeUnit unit,
                                   long upper,
                                   long lower,
                                   long growBy)
        Creates a new LinearDelay with a custom boundaries and factor.
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        lower - the lower boundary.
        growBy - the multiplication factor.
        Returns:
        a created LinearDelay.
      • exponential

        public static Delay exponential​(TimeUnit unit)
        Creates a new ExponentialDelay with default boundaries and factor (1, 2, 4, 8, 16, 32...).
        Parameters:
        unit - the unit of the delay.
        Returns:
        a created ExponentialDelay.
      • exponential

        public static Delay exponential​(TimeUnit unit,
                                        long upper)
        Creates a new ExponentialDelay with custom upper boundary and default factor (eg. with upper 8: 1, 2, 4, 8, 8, 8...).
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        Returns:
        a created ExponentialDelay.
      • exponential

        public static Delay exponential​(TimeUnit unit,
                                        long upper,
                                        long lower)
        Creates a new ExponentialDelay with custom boundaries and default factor (eg. with upper 8, lower 3: 3, 3, 4, 8, 8, 8...).
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        lower - the lower boundary.
        Returns:
        a created ExponentialDelay.
      • exponential

        public static Delay exponential​(TimeUnit unit,
                                        long upper,
                                        long lower,
                                        long growBy)
        Creates a new ExponentialDelay with custom boundaries and factor (eg. with upper 300, lower 0, growBy 10: 10, 20, 40, 80, 160, 300, ...).
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        lower - the lower boundary.
        growBy - the multiplication factor.
        Returns:
        a created ExponentialDelay.
      • exponential

        public static Delay exponential​(TimeUnit unit,
                                        long upper,
                                        long lower,
                                        long growBy,
                                        int powersOf)
        Creates a new ExponentialDelay on a base different from powers of two, with custom boundaries and factor (eg. with upper 9000, lower 0, growBy 3, powerOf 10: 3, 30, 300, 3000, 9000, 9000, 9000, ...).
        Parameters:
        unit - the unit of the delay.
        upper - the upper boundary.
        lower - the lower boundary.
        growBy - the multiplication factor (or basis for the size of each delay).
        powersOf - the base for exponential growth (eg. powers of 2, powers of 10, etc...)
        Returns:
        a created ExponentialDelay.