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

io.sphere.sdk.search.SphereSearchSort Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.search;

import static io.sphere.sdk.utils.IterableUtils.toStream;
import static java.util.stream.Collectors.joining;

public class SphereSearchSort extends SearchSortBase {
    private final SearchModel path;
    private final SearchSortDirection direction;

    protected SphereSearchSort(SearchModel path, SearchSortDirection direction) {
        this.path = path;
        this.direction = direction;
    }

    public String toSphereSort() {
        return renderPath(path) + " " + directionToString();
    }

    private String directionToString() {
        return direction.toString().toLowerCase().replace("_", ".");
    }

    private String renderPath(final SearchModel model) {
        return toStream(model.buildPath()).collect(joining("."));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy