Package com.azure.core.util.polling
Class PollResponse<T>
java.lang.Object
com.azure.core.util.polling.PollResponse<T>
- Type Parameters:
T- Type of poll response value.
PollResponse represents a single response from a service for a long-running polling operation. It provides
information such as the current
status of the long-running operation, any
value returned in the poll, as well as other useful information provided by the service.
Code Sample Creating PollResponse Object
// Lets say we want to crete poll response with status as IN_PROGRESS
PollResponse<String> inProgressPollResponse
= new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, "my custom response");
Code Sample Creating PollResponse Object with custom status
// Lets say we want to crete poll response with custom status as OTHER_CUSTOM_STATUS
PollResponse<String> pollResponseWithCustomStatus
= new PollResponse<>(LongRunningOperationStatus.fromString("OTHER_CUSTOM_STATUS", false),
"my custom status response");
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPollResponse(LongRunningOperationStatus status, T value) Creates a newPollResponsewith status and value.PollResponse(LongRunningOperationStatus status, T value, Duration retryAfter) Creates a newPollResponsewith status, value, retryAfter and properties. -
Method Summary
Modifier and TypeMethodDescriptionReturns the delay the service has requested until the next polling operation is performed.Represents the status of the long-running operation at the time the last polling operation finished successfully.getValue()The value returned as a result of the last successful poll operation.
-
Constructor Details
-
PollResponse
Creates a newPollResponsewith status, value, retryAfter and properties.Code Sample Creating PollResponse Object
// Lets say we want to crete poll response with status as IN_PROGRESS PollResponse<String> inProgressPollResponse = new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, "my custom response", Duration.ofMillis(2000));- Parameters:
status- Mandatory operation status as defined inLongRunningOperationStatus.value- The value as a result of poll operation. This can be any custom user-defined object. Null is also valid.retryAfter- Represents the delay the service has requested until the next polling operation is performed. Anull, zero or negative value will be taken to mean that the poller should determine on its own when the next poll operation is to occur.- Throws:
NullPointerException- Ifstatusisnull.
-
PollResponse
Creates a newPollResponsewith status and value.Code Sample Creating PollResponse Object
// Lets say we want to crete poll response with status as IN_PROGRESS PollResponse<String> inProgressPollResponse = new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, "my custom response");- Parameters:
status- Mandatory operation status as defined inLongRunningOperationStatus.value- The value as a result of poll operation. This can be any custom user-defined object. Null is also valid.- Throws:
NullPointerException- Ifstatusisnull.
-
-
Method Details
-
getStatus
Represents the status of the long-running operation at the time the last polling operation finished successfully.- Returns:
- A
LongRunningOperationStatusrepresenting the result of the poll operation.
-
getValue
The value returned as a result of the last successful poll operation. This can be any custom user defined object, or null if no value was returned from the service.- Returns:
- T result of poll operation.
-
getRetryAfter
Returns the delay the service has requested until the next polling operation is performed. A null or negative value will be taken to mean that the poller should determine on its own when the next poll operation is to occur.- Returns:
- Duration How long to wait before next retry.
-