public boolean wantsNotification(String userId, NotificationType notificationType, NotificationDto<?> notification) {
        RuleKey key = RuleKey.of(userId, notificationType);
        ActivationRuleGroup ruleGroup = notificationsRuleCache.get(key,
                k -> notificationRepository.getNotificationPreferenceByUserIdAndType(userId, notificationType).map(entity -> buildRuleGroup(entity, key)).orElse(null));
        if (ruleGroup == null) {
            return true;
        }
        Facts facts = new Facts();
        facts.add(new Fact<>("notification", notification));
        return !ruleGroup.evaluate(facts);
    }
NotificationRulesService builds and caches {@link NotificationPreferenceEntity} simple rules on filtering notifications.

<p>This enables notification dispatchers to determine whether a given user wants to ignore a particular type or medium of notification.

<p>Rules are cached for a short period to avoid excessive database invocations and frequently rebuilding rulesets.

@author Marc Savy {@literal <marc@blackparrotlabs.io>}
manager/api/rest-impl/src/main/java/io/apiman/manager/api/notifications/NotificationRulesService.java