Class JsonNotificationCallback<T> (2.1.2)

public abstract class JsonNotificationCallback<T> extends TypedNotificationCallback<T>

Beta
A TypedNotificationCallback which uses an JSON content encoding.

Must NOT be implemented in form of an anonymous class as this will break serialization.

Implementation should be thread-safe. Example usage:


 static class MyNotificationCallback
     extends JsonNotificationCallback{@literal <}listresponse{@literal>} {

   private static final long serialVersionUID = 1L;

   {@literal @}Override
   protected void onNotification(StoredChannel channel,
       TypedNotification{@literal <}listresponse{@literal>} notification) {
     ListResponse content = notification.getContent();
     switch (notification.getResourceState()) {
       case ResourceStates.SYNC:
         break;
       case ResourceStates.EXISTS:
         break;
       case ResourceStates.NOT_EXISTS:
         break;
    }
   }

   {@literal @}Override
   protected JsonFactory getJsonFactory() throws IOException {
     return new GsonFactory();
   }

   {@literal @}Override
   protected Class{@literal <}listresponse{@literal>} getDataClass() throws IOException {
     return ListResponse.class;
   }
 }
 

Inheritance

java.lang.Object > TypedNotificationCallback > JsonNotificationCallback<T>

Type Parameter

NameDescription
T

Constructors

JsonNotificationCallback()

public JsonNotificationCallback()

Methods

getJsonFactory()

protected abstract JsonFactory getJsonFactory()

Returns the JSON factory to use to parse the notification content.

Returns
TypeDescription
com.google.api.client.json.JsonFactory
Exceptions
TypeDescription
IOException

getObjectParser()

protected final JsonObjectParser getObjectParser()

Returns an ObjectParser which can be used to parse this notification.

Returns
TypeDescription
com.google.api.client.json.JsonObjectParser
Overrides
Exceptions
TypeDescription
IOException