Package com.google.cloud
Class BatchResult<T,E extends BaseServiceException>
- java.lang.Object
-
- com.google.cloud.BatchResult<T,E>
-
- Type Parameters:
T
- the type of the resultE
- the type of the service-dependent exception thrown when a processing error occurs
public abstract class BatchResult<T,E extends BaseServiceException> extends Object
This class holds a single result of a batch call. The class is not thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BatchResult.Callback<T,E>
An interface for the batch callbacks.
-
Constructor Summary
Constructors Modifier Constructor Description protected
BatchResult()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
completed()
Returnstrue
if the batch has been completed and the result is available;false
otherwise.protected void
error(E error)
Sets an error and status as completed.T
get()
Returns the result of this call.void
notify(BatchResult.Callback<T,E> callback)
Adds a callback for the batch operation.protected void
success(T result)
Sets a result and status as completed.
-
-
-
Method Detail
-
completed
public boolean completed()
Returnstrue
if the batch has been completed and the result is available;false
otherwise.
-
get
public T get() throws E extends BaseServiceException
Returns the result of this call.- Throws:
IllegalStateException
- if the batch has not been completed yetE
- if an error occurred when processing the batch requestE extends BaseServiceException
-
notify
public void notify(BatchResult.Callback<T,E> callback)
Adds a callback for the batch operation.- Throws:
IllegalStateException
- if the batch has been completed already
-
error
protected void error(E error)
Sets an error and status as completed. Notifies all callbacks.
-
success
protected void success(T result)
Sets a result and status as completed. Notifies all callbacks.
-
-