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

io.sphere.sdk.search.model.FacetRange Maven / Gradle / Ivy

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

import javax.annotation.Nullable;

/**
 * Facet ranges should be of the form [a, b), (-∞, b) or [a, +∞).
 * @param  type of the range domain.
 */
public class FacetRange> extends Range {

    private FacetRange(@Nullable final Bound lowerBound, final Bound upperBound) {
        super(lowerBound, upperBound);
    }

    /**
     * Creates an interval with the given lower and upper endpoints.
     * @param lowerEndpoint lower endpoint, included in the range.
     * @param upperEndpoint upper endpoint, excluded in the range.
     * @param  type of the range domain.
     * @return the range with the given bounds of the form [a, b).
     * @throws InvertedBoundsException if the lower endpoint is greater than the upper endpoint.
     */
    public static > FacetRange of(final T lowerEndpoint, final T upperEndpoint) {
        return new FacetRange<>(Bound.inclusive(lowerEndpoint), Bound.exclusive(upperEndpoint));
    }

    /**
     * Creates an interval with all values that are strictly less than the given endpoint.
     * @param upperEndpoint upper endpoint, excluded in the range.
     * @param  type of the range domain.
     * @return the range of the form (-∞, b).
     */
    public static > FacetRange lessThan(final T upperEndpoint) {
        return new FacetRange<>(null, Bound.exclusive(upperEndpoint));
    }

    /**
     * Creates an interval with all values that are greater than or equal to the given endpoint.
     * @param lowerEndpoint lower endpoint, included in the range.
     * @param  type of the range domain.
     * @return the range of the form [a, +∞).
     */
    public static > FacetRange atLeast(final T lowerEndpoint) {
        return new FacetRange<>(Bound.inclusive(lowerEndpoint), null);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy