class ComponentResourceImpl implements ComponentResource {

    @Override
    public ComponentIndices getIndex(final String language, final boolean includeIconContent, final String query) {
        final Locale locale = localeMapper.mapLocale(language);
        caches.evictIfNeeded(indicesPerRequest, configuration.getMaxCacheSize() - 1);
        return indicesPerRequest.computeIfAbsent(new RequestKey(locale, includeIconContent, query), k -> {
            final Predicate<ComponentIndex> filter = queryLanguageCompiler.compile(query, componentEvaluators);
            return new ComponentIndices(Stream
                    .concat(findDeployedComponents(includeIconContent, locale),
                            virtualComponents
                                    .getDetails()
                                    .stream()
                                    .map(detail -> new ComponentIndex(detail.getId(), detail.getDisplayName(),
                                            detail.getId().getFamily(), new Icon(detail.getIcon(), null, null),
                                            new Icon(virtualComponents.getFamilyIconFor(detail.getId().getFamilyId()),
                                                    null, null),
                                            detail.getVersion(), singletonList(detail.getId().getFamily()),
                                            detail.getLinks())))
                    .filter(filter)
                    .collect(toList()));
        });
    }

}