Class GaePendingResult<T,​R extends ApiResponse<T>>

java.lang.Object
ai.nextbillion.maps.internal.GaePendingResult<T,​R>
All Implemented Interfaces:
PendingResult<T>

public class GaePendingResult<T,​R extends ApiResponse<T>>
extends java.lang.Object
implements PendingResult<T>
A PendingResult backed by a HTTP call executed by Google App Engine URL Fetch capability, a deserialization step using Gson, and a retry policy.

T is the type of the result of this pending result, and R is the type of the request.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface ai.nextbillion.maps.PendingResult

    PendingResult.Callback<T>
  • Constructor Summary

    Constructors 
    Constructor Description
    GaePendingResult​(com.google.appengine.api.urlfetch.HTTPRequest request, com.google.appengine.api.urlfetch.URLFetchService client, java.lang.Class<R> responseClass, com.google.gson.FieldNamingPolicy fieldNamingPolicy, long errorTimeOut, java.lang.Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry, RequestMetrics metrics)  
  • Method Summary

    Modifier and Type Method Description
    T await()
    Performs the request synchronously.
    T awaitIgnoreError()
    Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.
    void cancel()
    Attempts to cancel the request.
    void setCallback​(PendingResult.Callback<T> callback)
    Performs the request asynchronously, calling onResult or onFailure after the request has been completed.

    Methods inherited from class java.lang.Object

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

    • GaePendingResult

      public GaePendingResult​(com.google.appengine.api.urlfetch.HTTPRequest request, com.google.appengine.api.urlfetch.URLFetchService client, java.lang.Class<R> responseClass, com.google.gson.FieldNamingPolicy fieldNamingPolicy, long errorTimeOut, java.lang.Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry, RequestMetrics metrics)
      Parameters:
      request - HTTP request to execute.
      client - The client used to execute the request.
      responseClass - Model class to unmarshal JSON body content.
      fieldNamingPolicy - FieldNamingPolicy for unmarshaling JSON.
      errorTimeOut - Number of milliseconds to re-send erroring requests.
      maxRetries - Number of times allowed to re-send erroring requests.
      exceptionsAllowedToRetry - exceptionsAllowedToRetry
      metrics - metrics
  • Method Details

    • setCallback

      public void setCallback​(PendingResult.Callback<T> callback)
      Description copied from interface: PendingResult
      Performs the request asynchronously, calling onResult or onFailure after the request has been completed.
      Specified by:
      setCallback in interface PendingResult<T>
      Parameters:
      callback - The callback to call on completion.
    • await

      public T await() throws ApiException, java.io.IOException, java.lang.InterruptedException
      Description copied from interface: PendingResult
      Performs the request synchronously.
      Specified by:
      await in interface PendingResult<T>
      Returns:
      The result.
      Throws:
      ApiException - Thrown if the API Returned result is an error.
      java.io.IOException - Thrown when an I/O exception of some sort has occurred.
      java.lang.InterruptedException - Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted.
    • awaitIgnoreError

      public T awaitIgnoreError()
      Description copied from interface: PendingResult
      Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.
      Specified by:
      awaitIgnoreError in interface PendingResult<T>
      Returns:
      The result, or null if there was any error or exception ignored.
    • cancel

      public void cancel()
      Description copied from interface: PendingResult
      Attempts to cancel the request.
      Specified by:
      cancel in interface PendingResult<T>