All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.internal.util.SearchResultUtil Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy