Source:
<code>protected static String buildQueryStringWithPageProvider(PageProvider provider, boolean useAggregates) { String quickFiltersClause = ""; List<QuickFilter> quickFilters = provider.getQuickFilters(); if (quickFilters != null) { for (QuickFilter quickFilter : quickFilters) { String clause = quickFilter.getClause(); if (!quickFiltersClause.isEmpty() && clause != null) { quickFiltersClause = NXQLQueryBuilder.appendClause(quickFiltersClause, clause); } else { quickFiltersClause = StringUtils.defaultString(clause); } } } String aggregatesClause = useAggregates ? buildAggregatesClause(provider) : null; PageProviderDefinition def = provider.getDefinition(); WhereClauseDefinition whereClause = def.getWhereClause(); DocumentModel searchDocumentModel = provider.getSearchDocumentModel(); Object[] parameters = provider.getParameters(); String query; if (whereClause == null) { String pattern = def.getPattern(); if (!quickFiltersClause.isEmpty()) { pattern = appendToPattern(pattern, quickFiltersClause); } if (StringUtils.isNotEmpty(aggregatesClause)) { pattern = appendToPattern(pattern, aggregatesClause); } query = NXQLQueryBuilder.getQuery(pattern, parameters, def.getQuotePatternParameters(), def.getEscapePatternParameters(), searchDocumentModel, null); } else { if (searchDocumentModel == null) { throw new NuxeoException( String.format("Cannot build query of provider '%s': " + "no search document model is set", provider.getName())); } String additionalClause = aggregatesClause; if (StringUtils.isNotEmpty(quickFiltersClause)) { additionalClause = StringUtils.isNotEmpty(additionalClause) ? NXQLQueryBuilder.appendClause(additionalClause, quickFiltersClause) : quickFiltersClause; <START> } <END> query = NXQLQueryBuilder.getQuery(searchDocumentModel, whereClause, additionalClause, parameters, null); } return query; }</code><technical_language>more readable do single-assignment avoid negations, avoiding ?: in this case: String additionalClause; if (StringUtils.isEmpty(quickFiltersClause)) { additionalClause = aggregatesClause; } else if (StringUtils.isEmpty(aggregatesClause)) { additionalClause = quickFiltersClause; } else { additionalClause = NXQLQueryBuilder.appendClause(aggregatesClause, quickFiltersClause); } NXQLQueryBuilder.appendClause do this work itself..</technical_language>

Target:
protected static String buildQueryStringWithPageProvider(PageProvider provider, boolean useAggregates) { String quickFiltersClause = ""; List<QuickFilter> quickFilters = provider.getQuickFilters(); if (quickFilters != null) { for (QuickFilter quickFilter : quickFilters) { String clause = quickFilter.getClause(); if (!quickFiltersClause.isEmpty() && clause != null) { quickFiltersClause = NXQLQueryBuilder.appendClause(quickFiltersClause, clause); } else { quickFiltersClause = StringUtils.defaultString(clause); } } } String aggregatesClause = useAggregates ? buildAggregatesClause(provider) : null; PageProviderDefinition def = provider.getDefinition(); WhereClauseDefinition whereClause = def.getWhereClause(); DocumentModel searchDocumentModel = provider.getSearchDocumentModel(); Object[] parameters = provider.getParameters(); String query; if (whereClause == null) { String pattern = def.getPattern(); if (!quickFiltersClause.isEmpty()) { pattern = appendToPattern(pattern, quickFiltersClause); } if (StringUtils.isNotEmpty(aggregatesClause)) { pattern = appendToPattern(pattern, aggregatesClause); } query = NXQLQueryBuilder.getQuery(pattern, parameters, def.getQuotePatternParameters(), def.getEscapePatternParameters(), searchDocumentModel, null); } else { if (searchDocumentModel == null) { throw new NuxeoException( String.format("Cannot build query of provider '%s': " + "no search document model is set", provider.getName())); } String additionalClause = NXQLQueryBuilder.appendClause(aggregatesClause, quickFiltersClause); query = NXQLQueryBuilder.getQuery(searchDocumentModel, whereClause, additionalClause, parameters, null); } return query; }