Interface NotifBook.NotificationDescriptionHandler

Enclosing class:
NotifBook

public static interface NotifBook.NotificationDescriptionHandler
This Java interface must be implemented by classes that filter notification descriptions. This is needed when you need to search in the Notification Book for a specific notification description based on its attributes. Here is an implementation filtering all the notification descriptions but the notification with 'FAILURE' as level:
   public boolean handle(NotificationDescription desc) {
       if (desc == null) {
          throw new IllegalArgumentException("null argument 'desc'");
       }
       if (desc.getSeverityLevel() ==  NotificationLevel.FAILURE) {
           failureNotification.add(desc);
       }
       // return true because all the notification descriptions must be checked.
       return true;
   }
   private List failureNotification = new ArrayList();
 
Another example to search a notification description by its name:
   public void setNotificationName(String name) {
       this.notificationName = name;
   }
   public boolean handle(NotificationDescription desc) {
       if (notificationName == null) {
           throw new IllegalArgumentException("null argument 'desc'");
       }
       if (desc.getName().equalsIgnoreCase(notificationName)) {
           description = desc;
           return false;
       }
       return true;
   }
   private NotificationDescription description = null;
   private String notificationName;
 
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Receives a notification description.
  • Method Details

    • handle

      boolean handle(NotificationDescription desc)
      Receives a notification description.
      Parameters:
      desc - The notification description to be handled
      Returns:
      true if this handler expects another desc, false otherwise.