class RoleContextualPreferenceHandler extends AbstractDaoContextualPreferenceHandler {

    @Override
    public Optional<ContextualPreference> search(final List<String> preferences,
                                                 final List<ContextualPreferenceExternalResource> resources) {
        final List<ContextualPreferenceExternalResource> roleResources = resources.stream()
                .filter(res -> res.getLevel() == level)
                .collect(Collectors.toList());
        final Optional<ContextualPreference> reducedPreference = preferences.stream()
                .map(pref -> roleResources.stream()
                        .map(res -> loadPreference(pref, res))
                        .filter(Optional::isPresent)
                        .map(Optional::get)
                        .collect(Collectors.toList()))
                .filter(CollectionUtils::isNotEmpty)
                .findFirst()
                .flatMap(reducer::reduce);
        return reducedPreference.isPresent()
                ? reducedPreference
                : searchUsingNextHandler(preferences, resources);
    }

    public  RoleContextualPreferenceHandler(final RoleDao roleDao,
                                           final ContextualPreferenceDao contextualPreferenceDao,
                                           final ContextualPreferenceHandler nextHandler,
                                           final ContextualPreferenceReducer reducer);
    public  RoleContextualPreferenceHandler(final RoleDao roleDao,
                                           final ContextualPreferenceDao contextualPreferenceDao,
                                           final ContextualPreferenceReducer reducer);

}