com.gisgraphy.helper

## Class RetryOnErrorTemplate<T>

- java.lang.Object
- - com.gisgraphy.helper.RetryOnErrorTemplate<T>

-     public abstract class RetryOnErrorTemplate<T>
      extends Object

  Give the ability to retry a function multiple times if it fails.
  usage : `

       RetryOnErrorTemplate<String> retryOnError = new RetryOnErrorTemplate<String>() {
                  public String tryThat() throws Exception {
                      return THE_RETURNED_VALUE;
                  }
              };
       retryOnError.times(3)

  `
  Author:
    David Masclet

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static org.slf4j.Logger` | `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RetryOnErrorTemplate()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getAlreadyTry()`
    `String` | `getLoggingSentence()`
    `int` | `getNumberOfTimesToRetry()`
    `void` | `setLoggingSentence(String loggingSentence)`
    `T` | `times(int numberOfTry)`
    `abstract T` | `tryThat()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected static final org.slf4j.Logger logger

  - ### Constructor Detail

    - #### RetryOnErrorTemplate

          public RetryOnErrorTemplate()

  - ### Method Detail

    - #### tryThat

          public abstract T tryThat()
                             throws Exception

      Throws:
        `Exception`

    - #### times

          public T times(int numberOfTry)
                  throws Exception

      Throws:
        `Exception`

    - #### getAlreadyTry

          public int getAlreadyTry()

      Returns:
        The number of times the code has already been try

    - #### getNumberOfTimesToRetry

          public int getNumberOfTimesToRetry()

      Returns:
        The number of times the code should be try

    - #### getLoggingSentence

          public String getLoggingSentence()

      Returns:
        the loggingSentence

    - #### setLoggingSentence

          public void setLoggingSentence(String loggingSentence)

      Parameters:
        `loggingSentence` - the loggingSentence to set

Copyright © 2015. All rights reserved.