Class TypedNotificationCallback<T> (1.34.1)

public abstract class TypedNotificationCallback<T> implements UnparsedNotificationCallback

Beta
Callback to receive notifications for watched resource in which the . Callback which is used to receive typed AbstractNotifications after subscribing to a topic.

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 subscription, Notification notification, ListResponse content) {
     switch (notification.getResourceState()) {
       case ResourceStates.SYNC:
         break;
       case ResourceStates.EXISTS:
         break;
       case ResourceStates.NOT_EXISTS:
         break;
     }
   }

    {@literal @}Override
    protected ObjectParser getObjectParser(Notification notification) throws IOException {
      return new JsonObjectParser(new GsonFactory());
    }

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

Inheritance

java.lang.Object > TypedNotificationCallback<T>

Type Parameter

NameDescription
T

Constructors

TypedNotificationCallback()

public TypedNotificationCallback()

Methods

getDataClass()

protected abstract Class<T> getDataClass()

Returns the data class to parse the notification content into or Void.class if no notification content is expected.

Returns
TypeDescription
Class<T>
Exceptions
TypeDescription
IOException

getObjectParser()

protected abstract ObjectParser getObjectParser()

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

Returns
TypeDescription
com.google.api.client.util.ObjectParser
Exceptions
TypeDescription
IOException

onNotification(StoredChannel storedChannel, TypedNotification<T> notification)

protected abstract void onNotification(StoredChannel storedChannel, TypedNotification<T> notification)

Handles a received typed notification.

Parameters
NameDescription
storedChannelStoredChannel

stored notification channel

notificationTypedNotification<T>

typed notification

Exceptions
TypeDescription
IOException

onNotification(StoredChannel storedChannel, UnparsedNotification notification)

public final void onNotification(StoredChannel storedChannel, UnparsedNotification notification)

Handles a received unparsed notification.

Parameters
NameDescription
storedChannelStoredChannel
notificationUnparsedNotification
Exceptions
TypeDescription
IOException