Created
February 7, 2012 18:50
-
-
Save adamv/1761199 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RetryCounter { | |
private final int maxAttempts; | |
private int attempts; | |
private boolean successful; | |
public RetryCounter(final int maxAttempts) { | |
this.maxAttempts = maxAttempts; | |
this.attempts = 0; | |
this.successful = false; | |
} | |
public void attempt(final boolean wasSuccessful) { | |
this.attempts++; | |
this.successful = wasSuccessful; | |
} | |
public boolean shouldTryAgain() { | |
return !successful && attempts < maxAttempts; | |
} | |
public boolean wasSuccessful() { | |
return successful; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment