
io.sphere.internal.util.SearchResultUtil Maven / Gradle / Ivy
package io.sphere.internal.util;
import io.sphere.client.model.SearchResult;
import java.util.Collection;
public class SearchResultUtil {
// static so that it does not show up in code completion on SearchResult
/** Transforms the results of a SearchResult. */
public static SearchResult transform(SearchResult res, Collection results) {
return transform(res, results, null);
}
/** Sets the pageSize of a SearchResult, and potentially transforms results. */
public static SearchResult transform(SearchResult res, Collection results, Integer pageSize) {
if (results == null) throw new NullPointerException("results");
if (results.size() != res.getResults().size())
throw new IllegalArgumentException("When transforming a SearchResult, the number of results must stay unchanged.");
return new SearchResult(
res.getOffset(),
res.getCount(),
res.getTotal(),
results,
res.getFacetsRaw(),
pageSize != null ? pageSize : res.getPageSize());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy