Package org.xwiki.notifications.filters
Interface NotificationFilter
-
- All Superinterfaces:
Comparable
@Role public interface NotificationFilter extends Comparable
Enable or disable notifications from the event stream (for customization purpose). ANotificationFilterhas two goals :- Pre-Filtering : Generate a query (made with
AbstractNode) that will be used to retrieve a specific subset of notifications from a provider. - Post-Filtering : given an
Event, determine if this event should be filtered or not.
- Since:
- 9.5RC1
- Version:
- $Id: fbf72bc5db8c3771ebe435e6d5fcda195204b6a0 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classNotificationFilter.FilteringPhaseThe different phases when a filter can be called.static classNotificationFilter.FilterPolicyThe different behaviours a filter could have regarding an event.
-
Field Summary
Fields Modifier and Type Field Description static Set<NotificationFilter.FilteringPhase>SUPPORT_BOTH_FILTERING_PHASEA static set containing bothNotificationFilter.FilteringPhase.POST_FILTERINGandNotificationFilter.FilteringPhase.PRE_FILTERING.static Set<NotificationFilter.FilteringPhase>SUPPORT_ONLY_POST_FILTERING_PHASEA static set containing onlyNotificationFilter.FilteringPhase.POST_FILTERING.static Set<NotificationFilter.FilteringPhase>SUPPORT_ONLY_PRE_FILTERING_PHASEA static set containing onlyNotificationFilter.FilteringPhase.PRE_FILTERING.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default intcompareTo(Object o)NotificationFilter.FilterPolicyfilterEvent(org.xwiki.eventstream.Event event, DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFormat format)Enable or disable an event in the notification list (post-filter).ExpressionNodefilterExpression(DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFilterType type, NotificationFormat format)Filtering expression to use when retrieving notifications.default ExpressionNodefilterExpression(DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFilterType type, NotificationFormat format, Collection<NotificationPreference> preferences)Filtering expression to use when retrieving notifications.ExpressionNodefilterExpression(DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationPreference preference)Filtering expression to use when retrieving notifications.default Set<NotificationFilter.FilteringPhase>getFilteringPhases()StringgetName()Get the name of the filter.default intgetPriority()booleanmatchesPreference(NotificationPreference preference)Determine if the current filter can be applied to the given preference.
-
-
-
Field Detail
-
SUPPORT_BOTH_FILTERING_PHASE
static final Set<NotificationFilter.FilteringPhase> SUPPORT_BOTH_FILTERING_PHASE
A static set containing bothNotificationFilter.FilteringPhase.POST_FILTERINGandNotificationFilter.FilteringPhase.PRE_FILTERING. To be used in overrides ofgetFilteringPhases()for performance reasons.
-
SUPPORT_ONLY_POST_FILTERING_PHASE
static final Set<NotificationFilter.FilteringPhase> SUPPORT_ONLY_POST_FILTERING_PHASE
A static set containing onlyNotificationFilter.FilteringPhase.POST_FILTERING. To be used in overrides ofgetFilteringPhases()for performance reasons.
-
SUPPORT_ONLY_PRE_FILTERING_PHASE
static final Set<NotificationFilter.FilteringPhase> SUPPORT_ONLY_PRE_FILTERING_PHASE
A static set containing onlyNotificationFilter.FilteringPhase.PRE_FILTERING. To be used in overrides ofgetFilteringPhases()for performance reasons.
-
-
Method Detail
-
filterEvent
NotificationFilter.FilterPolicy filterEvent(org.xwiki.eventstream.Event event, DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFormat format)
Enable or disable an event in the notification list (post-filter).- Parameters:
event- an eventuser- the user interested in the notificationfilterPreferences- the collection of all preferences to take into accountformat- format of the notification- Returns:
- true if the event should be dismiss
- Since:
- 9.11.5, 10.3
-
matchesPreference
boolean matchesPreference(NotificationPreference preference)
Determine if the current filter can be applied to the given preference. In order to do so, theNotificationFiltercan rely on the different parameters of theNotificationPreference.- Parameters:
preference- the preference to use- Returns:
- true if the filter is compatible with the preference
- Since:
- 9.7RC1
-
filterExpression
ExpressionNode filterExpression(DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationPreference preference)
Filtering expression to use when retrieving notifications.- Parameters:
user- the user interested in the notificationsfilterPreferences- the collection of all preferences to take into accountpreference- the notification preference associated with the filter- Returns:
- the updated query
- Since:
- 9.7RC1
-
filterExpression
ExpressionNode filterExpression(DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFilterType type, NotificationFormat format)
Filtering expression to use when retrieving notifications. Note that this filtering expression will not be bound to any notification preference.- Parameters:
user- the user interested in the notificationsfilterPreferences- the collection of all preferences to take into accounttype- of the expected notification filterformat- format of the notification- Returns:
- a filtering expression or null
- Since:
- 9.10RC1
-
filterExpression
default ExpressionNode filterExpression(DocumentReference user, Collection<NotificationFilterPreference> filterPreferences, NotificationFilterType type, NotificationFormat format, Collection<NotificationPreference> preferences)
Filtering expression to use when retrieving notifications. Note that this filtering expression will not be bound to any notification preference.- Parameters:
user- the user interested in the notificationsfilterPreferences- the collection of all preferences to take into accounttype- of the expected notification filterformat- format of the notificationpreferences- list of preferences- Returns:
- a filtering expression or null
- Since:
- 10.8RC1, 9.11.8
-
getName
String getName()
Get the name of the filter. This is useful asNotificationFilterPreferencewill be able to be linked to this filter using its name. If theNotificationFilteris used as a component, consider defining the hint of this component as the name of the filter.- Returns:
- the name of the filter
- Since:
- 9.7RC1
-
getPriority
default int getPriority()
- Returns:
- the priority of the filter. The higher it is, the more important the result of
filterEvent(Event, DocumentReference, Collection, NotificationFormat)is. - Since:
- 9.11.5, 10.3
-
compareTo
default int compareTo(Object o)
- Specified by:
compareToin interfaceComparable
-
getFilteringPhases
default Set<NotificationFilter.FilteringPhase> getFilteringPhases()
- Returns:
- the set of pĥase(s) when the filter can be used.
- Since:
- 12.9RC1, 12.6.3
-
-