Class CommonGoogleProtoClientRequestInitializer (1.33.4)

public class CommonGoogleProtoClientRequestInitializer extends CommonGoogleClientRequestInitializer

Beta
Google protocol buffer 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 =
   new CommonGoogleProtoClientRequestInitializer(KEY);
 

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


 public static final GoogleClientRequestInitializer INITIALIZER =
   new CommonGoogleProtoClientRequestInitializer(KEY, USER_IP);
 

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


 public static class MyRequestInitializer extends CommonGoogleProtoClientRequestInitializer {

  {@literal @}Override
  public void initialize(AbstractGoogleProtoClientRequest{@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 CommonGoogleProtoClientRequestInitializer {

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

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

Subclasses should be thread-safe.

Inheritance

java.lang.Object > CommonGoogleClientRequestInitializer > CommonGoogleProtoClientRequestInitializer

Constructors

CommonGoogleProtoClientRequestInitializer()

public CommonGoogleProtoClientRequestInitializer()

CommonGoogleProtoClientRequestInitializer(String key)

public CommonGoogleProtoClientRequestInitializer(String key)
Parameter
NameDescription
keyString

API key or null to leave it unchanged

CommonGoogleProtoClientRequestInitializer(String key, String userIp)

public CommonGoogleProtoClientRequestInitializer(String key, String userIp)
Parameters
NameDescription
keyString

API key or null to leave it unchanged

userIpString

user IP or null to leave it unchanged

Methods

initialize(AbstractGoogleClientRequest<?> request)

public final void initialize(AbstractGoogleClientRequest<?> request)

Subclasses should call super implementation in order to set the key and userIp.

Parameter
NameDescription
requestAbstractGoogleClientRequest<?>
Overrides Exceptions
TypeDescription
IOException

initializeProtoRequest(AbstractGoogleProtoClientRequest<?> request)

protected void initializeProtoRequest(AbstractGoogleProtoClientRequest<?> request)

Initializes a Google protocol buffer client request.

Default implementation does nothing. Called from #initialize(AbstractGoogleClientRequest).

Parameter
NameDescription
requestAbstractGoogleProtoClientRequest<?>
Exceptions
TypeDescription
IOException

I/O exception