Class BatchResult<T,E extends BaseServiceException>

java.lang.Object
com.google.cloud.BatchResult<T,E>
Type Parameters:
T - the type of the result
E - 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 
    An interface for the batch callbacks.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true 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.
    get()
    Returns the result of this call.
    void
    Adds a callback for the batch operation.
    protected void
    success(T result)
    Sets a result and status as completed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BatchResult

      @InternalApi("This class should only be extended within google-cloud-java") protected BatchResult()
  • Method Details

    • completed

      public boolean completed()
      Returns true if the batch has been completed and the result is available; false otherwise.
    • get

      public T get() throws E
      Returns the result of this call.
      Throws:
      IllegalStateException - if the batch has not been completed yet
      E - if an error occurred when processing the batch request
    • 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.