Skip to content

Commit

Permalink
Move toString() out of the builder class (resilience4j#1913)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Dias <mdias@atlassian.com>
  • Loading branch information
mikedias and mdias-atlassian committed Mar 29, 2023
1 parent ad06f98 commit b526a26
Showing 1 changed file with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.Serializable;
import java.time.Duration;
import java.util.Arrays;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
Expand Down Expand Up @@ -140,7 +141,7 @@ public Predicate<Throwable> getExceptionPredicate() {
}

/**
* Return the Predicate which evaluates if an result should be retried. The Predicate must
* Return the Predicate which evaluates if a result should be retried. The Predicate must
* return true if the result should be retried, otherwise it must return false.
*
* @param <T> The type of result.
Expand All @@ -161,6 +162,32 @@ public <T> Predicate<T> getResultPredicate() {
public <T> BiConsumer<Integer, T> getConsumeResultBeforeRetryAttempt(){
return consumeResultBeforeRetryAttempt;
}
@Override
public String toString() {
StringBuilder retryConfig = new StringBuilder("RetryConfig {");
retryConfig.append("maxAttempts=");
retryConfig.append(maxAttempts);
retryConfig.append(", failAfterMaxAttempts=");
retryConfig.append(failAfterMaxAttempts);
retryConfig.append(", writableStackTraceEnabled=");
retryConfig.append(writableStackTraceEnabled);
retryConfig.append(", intervalFunction=");
retryConfig.append(intervalFunction);
retryConfig.append(", retryOnExceptionPredicate=");
retryConfig.append(retryOnExceptionPredicate);
retryConfig.append(", retryOnResultPredicate=");
retryConfig.append(retryOnResultPredicate);
retryConfig.append(", intervalBiFunction=");
retryConfig.append(intervalBiFunction);
retryConfig.append(", consumeResultBeforeRetryAttempt=");
retryConfig.append(consumeResultBeforeRetryAttempt);
retryConfig.append(", retryExceptions=");
retryConfig.append(Arrays.toString(retryExceptions));
retryConfig.append(", ignoreExceptions=");
retryConfig.append(Arrays.toString(ignoreExceptions));
retryConfig.append("}");
return retryConfig.toString();
}

public static class Builder<T> {

Expand All @@ -187,32 +214,6 @@ public static class Builder<T> {
@SuppressWarnings("unchecked")
private Class<? extends Throwable>[] ignoreExceptions = new Class[0];

@Override
public String toString() {
StringBuilder retryConfig = new StringBuilder("RetryConfig {");
retryConfig.append("maxAttempts=");
retryConfig.append(maxAttempts);
retryConfig.append(", failAfterMaxAttempts=");
retryConfig.append(failAfterMaxAttempts);
retryConfig.append(", writableStackTraceEnabled=");
retryConfig.append(writableStackTraceEnabled);
retryConfig.append(", intervalFunction=");
retryConfig.append(intervalFunction);
retryConfig.append(", retryOnExceptionPredicate=");
retryConfig.append(retryOnExceptionPredicate);
retryConfig.append(", retryOnResultPredicate=");
retryConfig.append(retryOnResultPredicate);
retryConfig.append(", intervalBiFunction=");
retryConfig.append(intervalBiFunction);
retryConfig.append(", consumeResultBeforeRetryAttempt=");
retryConfig.append(consumeResultBeforeRetryAttempt);
retryConfig.append(", retryExceptions=");
retryConfig.append(retryExceptions);
retryConfig.append(", ignoreExceptions=");
retryConfig.append(ignoreExceptions);
return retryConfig.toString();
}

public Builder() {
}

Expand Down

0 comments on commit b526a26

Please sign in to comment.