Source:
public <T extends Document> DocumentSearchResponse<T> search(final Query query, final Integer start, final Integer size, final Class<T> documentClass, final SortOrder sortOrder) { try { final DocumentConfiguration documentConfiguration = getDocumentConfiguration(documentClass); final SearchRequest searchRequest = getSearchRequest(query); searchRequest.setStart((long) start); searchRequest.setSize((long) size); if (sortOrder != null) { final StringBuffer sort = new StringBuffer(); String direction = null; final Iterator<SortingOption> i = sortOrder.sortingOptions().iterator(); while (i.hasNext()) { final SortingOption sortingOption = i.next(); if (!SortingOption.Key.DEFAULT.name().equals((sortingOption.key()))) { sort.append(sortingOption.key() + " "); switch (sortingOption.direction()) { case ASCENDING: direction = "asc"; break; case DESCENDING: direction = "desc"; break; default: direction = "asc"; break; } sort.append(direction); if (i.hasNext()) { sort.append(", "); } else { searchRequest.setSort(sort.toString()); } } } } final String searchDomain = documentConfigurationHolder.schemaName() + "-" + documentConfiguration.namespace(); final SearchResult searchResult = getSearchServiceClient(searchDomain).search(searchRequest); final List<T> documents = new ArrayList<>(); for (final Hit hit : searchResult.getHits().getHit()) { try { documents.add(getDocument(hit, documentClass, documentConfiguration.properties())); } catch (final Exception e) { throw new IllegalStateException("Could not create Document from CloudSearch response: " + hit, e); } } final long totalResults = searchResult.getHits().getFound(); final String cursor = searchResult.getHits().getCursor(); return new DocumentSearchResponse<T>((int) totalResults, cursor, documents); } catch (final AmazonServiceException e) { throw new PersistenceResourceFailureException("Unable to perform CloudSearch query", e); } }

Target:
public <T extends Document> DocumentSearchResponse<T> search(final Query query, final Integer start, final Integer size, final Class<T> documentClass, final SortOrder sortOrder) { if (sortOrder == null) { throw new IllegalArgumentException("Sort order cannot be null"); } try { final DocumentConfiguration documentConfiguration = getDocumentConfiguration(documentClass); final SearchRequest searchRequest = getSearchRequest(query); searchRequest.setStart((long) start); searchRequest.setSize((long) size); if (sortOrder != SortOrder.DEFAULT) { final StringBuilder sort = new StringBuilder(); String direction = null; int count = 0; for (final SortingOption sortingOption : sortOrder.sortingOptions()) { count++; sort.append(sortingOption.key() + " "); switch (sortingOption.direction()) { case ASCENDING: default: direction = "asc"; break; case DESCENDING: direction = "desc"; break; } sort.append(direction); if (count < sortOrder.sortingOptions().size()) { sort.append(", "); } } searchRequest.setSort(sort.toString()); } final String searchDomain = documentConfigurationHolder.schemaName() + "-" + documentConfiguration.namespace(); final SearchResult searchResult = getSearchServiceClient(searchDomain).search(searchRequest); final List<T> documents = new ArrayList<>(); for (final Hit hit : searchResult.getHits().getHit()) { try { documents.add(getDocument(hit, documentClass, documentConfiguration.properties())); } catch (final Exception e) { throw new IllegalStateException("Could not create Document from CloudSearch response: " + hit, e); } } final long totalResults = searchResult.getHits().getFound(); final String cursor = searchResult.getHits().getCursor(); return new DocumentSearchResponse<T>((int) totalResults, cursor, documents); } catch (final AmazonServiceException e) { throw new PersistenceResourceFailureException("Unable to perform CloudSearch query", e); } }