class AbstractDaoContextualPreferenceHandler extends AbstractContextualPreferenceHandler {

    @Override
    public Optional<ContextualPreference> search(final List<String> preferences,
                                                 final List<ContextualPreferenceExternalResource> resources) {
        final Optional<ContextualPreference> preference = resources.stream()
                .filter(res -> res.getLevel() == level)
                .findFirst()
                .map(res -> preferences.stream()
                        .map(pref -> loadPreference(pref, res))
                        .filter(Optional::isPresent)
                        .map(Optional::get))
                .flatMap(Stream::findFirst);
        return preference.isPresent()
                ? preference
                : searchUsingNextHandler(preferences, resources);
    }

      AbstractDaoContextualPreferenceHandler(final ContextualPreferenceLevel level,
                                           final ContextualPreferenceHandler nextHandler,
                                           final ContextualPreferenceDao contextualPreferenceDao);

}