class AttributeSearchQueryBuilder extends AbstractSearchQueryBuilderImpl implements ProductSearchQueryBuilder<Query> {

    @Override
    public List<Query> createQueryChain(final NavigationContext<Query> navigationContext, final String parameter, final Object value) {

        if (StringUtils.isBlank(parameter)) {
            return null;
        }

        final String escapedParameter = escapeValue(parameter);

        if (value instanceof Collection) {

            final Collection singleValues = (Collection) value;
            if (singleValues.size() > 1) {

                final BooleanQuery.Builder aggregatedQuery = new BooleanQuery.Builder();

                boolean hasClause = false;
                for (final Object item : singleValues) {

                    final Query clause = createAttributeQuery(escapedParameter, escapeValue(item));
                    if (clause != null) {
                        aggregatedQuery.add(clause, BooleanClause.Occur.SHOULD);
                        hasClause = true;
                    }

                }

                if (hasClause) {
                    return Collections.singletonList(aggregatedQuery.build());
                }

            } else if (singleValues.size() == 1) {

                final Query clause = createAttributeQuery(escapedParameter, escapeValue(singleValues.iterator().next()));
                if (clause != null) {
                    return Collections.singletonList(clause);
                }

            }
            return null;
        }

        final Query clause = createAttributeQuery(escapedParameter, escapeValue(value));
        if (clause != null) {
            return Collections.singletonList(clause);
        }
        return null;

    }

}