java.lang.Object
java.lang.Record
de.cuioss.http.client.retry.RetryContext
- Record Components:
operationName- descriptive name of the operation being retriedattemptNumber- current attempt number (1-based)
- All Implemented Interfaces:
Serializable
public record RetryContext(String operationName, int attemptNumber)
extends Record
implements Serializable
Context information for retry operations.
Provides immutable context data that can be used by retry strategies
to make decisions about retry behavior, logging, and metrics.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRetryContext(String operationName, int attemptNumber) Creates an instance of aRetryContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theattemptNumberrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static RetryContextCreates a new retry context for the first attempt.booleanChecks if this is the first attempt.Creates a new retry context for the next attempt.Returns the value of theoperationNamerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RetryContext
Creates an instance of aRetryContextrecord class.- Parameters:
operationName- the value for theoperationNamerecord componentattemptNumber- the value for theattemptNumberrecord component
-
-
Method Details
-
initial
Creates a new retry context for the first attempt.- Parameters:
operationName- descriptive name of the operation- Returns:
- retry context with attempt number 1
-
nextAttempt
Creates a new retry context for the next attempt.- Returns:
- retry context with incremented attempt number
-
isFirstAttempt
Checks if this is the first attempt.- Returns:
- true if this is attempt number 1
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
operationName
Returns the value of theoperationNamerecord component.- Returns:
- the value of the
operationNamerecord component
-
attemptNumber
Returns the value of theattemptNumberrecord component.- Returns:
- the value of the
attemptNumberrecord component
-