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 > CommonGoogleProtoClientRequestInitializerConstructors
CommonGoogleProtoClientRequestInitializer()
public CommonGoogleProtoClientRequestInitializer()
CommonGoogleProtoClientRequestInitializer(String key)
public CommonGoogleProtoClientRequestInitializer(String key)
Parameter | |
---|---|
Name | Description |
key |
String API key or |
CommonGoogleProtoClientRequestInitializer(String key, String userIp)
public CommonGoogleProtoClientRequestInitializer(String key, String userIp)
Parameters | |
---|---|
Name | Description |
key |
String API key or |
userIp |
String user IP or |
Methods
initialize(AbstractGoogleClientRequest<?> request)
public final void initialize(AbstractGoogleClientRequest<?> request)
Subclasses should call super implementation in order to set the key and userIp.
Parameter | |
---|---|
Name | Description |
request |
AbstractGoogleClientRequest<?> |
Exceptions | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
request |
AbstractGoogleProtoClientRequest<?> |
Exceptions | |
---|---|
Type | Description |
IOException |
I/O exception |