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

io.quarkus.redis.datasource.sortedset.Range Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.redis.datasource.sortedset;

public class Range {

    private final V min;
    private final V max;
    private final boolean inclusiveMin;
    private final boolean inclusiveMax;

    public static final Range UNBOUNDED = new Range<>(null, null);

    @SuppressWarnings("unchecked")
    public static  Range unbounded() {
        return (Range) UNBOUNDED;
    }

    public Range(V min, V max) {
        this.min = min;
        this.max = max;
        this.inclusiveMin = true;
        this.inclusiveMax = true;
    }

    public Range(V min, boolean inclusiveMin, V max, boolean inclusiveMax) {
        this.min = min;
        this.max = max;
        this.inclusiveMin = inclusiveMin;
        this.inclusiveMax = inclusiveMax;
    }

    public boolean isUnbounded() {
        return this == UNBOUNDED;
    }

    public String getLowerBound() {
        if (isUnbounded() || min == null || min.equals("-")) {
            return "-";
        }
        if (!inclusiveMin) {
            return "(" + min;
        } else {
            return "[" + min;
        }
    }

    public String getUpperBound() {
        if (isUnbounded() || max == null || max.equals("+")) {
            return "+";
        }
        if (!inclusiveMax) {
            return "(" + max;
        } else {
            return "[" + max;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy