Package com.google.api.client.googleapis.services.json (2.6.0)

Contains the basis for the generated service-specific libraries based on the JSON format.

Classes

AbstractGoogleJsonClient

Thread-safe Google JSON client.

AbstractGoogleJsonClient.Builder

Builder for AbstractGoogleJsonClient.

Implementation is not thread-safe.

AbstractGoogleJsonClientRequest<T>

Google JSON request for a AbstractGoogleJsonClient.

Implementation is not thread-safe.

CommonGoogleJsonClientRequestInitializer

Google JSON client request initializer implementation for setting properties like key and userIp.

The simplest usage is to use it to set the key parameter:


 public static final GoogleClientRequestInitializer KEY_INITIALIZER =
        CommonGoogleJsonClientRequestInitializer.newBuilder()
              .setKey(KEY)
              .build();
 

There is also a constructor to set both the key and userIp parameters:


 public static final GoogleClientRequestInitializer INITIALIZER =
       CommonGoogleJsonClientRequestInitializer.newBuilder()
              .setKey(KEY)
              .setUserIp(USER_IP)
              .build();
 

If you want to implement custom logic, extend it like this:


 public static class MyRequestInitializer extends CommonGoogleJsonClientRequestInitializer {

   {@literal @}Override
   public void initialize(AbstractGoogleJsonClientRequest{@literal <}?{@literal>} request)
     throws IOException {
     // custom logic
   }
 }
 

Finally, to set the key and userIp parameters and insert custom logic, extend it like this:


 public static class MyKeyRequestInitializer extends CommonGoogleJsonClientRequestInitializer {

   public MyKeyRequestInitializer() {
     super(KEY, USER_IP);
   }

   {@literal @}Override
   public void initializeJsonRequest
       (AbstractGoogleJsonClientRequest{@literal <}?{@literal>} request) throws IOException {
     // custom logic
   }
 }
 

Subclasses should be thread-safe.

CommonGoogleJsonClientRequestInitializer.Builder

Builder for CommonGoogleJsonClientRequestInitializer.