public static interface NotifBook.NotificationDescriptionHandler
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;
| Modifier and Type | Method and Description |
|---|---|
boolean |
handle(NotificationDescription desc)
Receives a notification description.
|
boolean handle(NotificationDescription desc)
desc - The notification description to be handled