title: How to retry a function call with Java?
body: <p>I am using a custom Java library to make REST API calls. I have functions which make api calls using that library. I want to be able to retry some api calls/functions, but the library does not provide that functionality. </p>
  
  <p>I'd like to retry an api call n times, OR for a certain amount of time, pausing x seconds between every execution. In all cases, the api call should be retried only until certain conditions are met, for example the Response (class) object response code == 200 and response body contains "successful !!!". I also want to be able to ignore certain exceptions while making these calls.</p>
  
  <p>Pseudocode for what I need :</p>
  
  <pre><code>    SuperLibrary superLibrary = new SuperLibrary();
      superLibrary.do(myApiCallFunction()).
                .handle(ConnectException.class)
                .withDelay(Duration.ofSeconds(3))
                //.withMaxTimeout(Duration.ofSeconds(15))//Also an option
                .withMaxRetries(3)
                .until(Some Conditions are true);
  </code></pre>
  
  <p>Is there any reliable and "simple" java library which allows me to do this ? I'd appreciate it if someone could point me to any code examples which do what I need.</p>
  
  <p>Thanks !</p>