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

fun.langel.cql.node.Range Maven / Gradle / Ivy

The newest version!
package fun.langel.cql.node;

import fun.langel.cql.util.ListUtil;

import java.util.List;

/**
 * @author [email protected](GuHan)
 * @since 2022/8/2 14:22
 **/
public class Range implements Terminal, Node, Expr {

    private List values;

    private Value begin;

    private Value end;

    private Type type;

    private Range(final List values) {
        this.values = values;
        this.type = Type.EXHAUSTIVELY;
    }

    public Range(final Value begin, final Value end) {
        this.begin = begin;
        this.end = end;
        this.type = Type.BOUNDARY;
    }


    public static Range of(final List values) {
        return new Range(values);
    }

    public static Range of(final Value begin, final Value end) {
        return new Range(begin, end);
    }

    public Value.Type valueType() {
        if (ListUtil.isNullOrEmpty(this.values())) {
            return Value.Type.STRING;
        }
        return this.values().get(0).type();
    }

    public List values() {
        return this.values;
    }

    public Value begin() {
        return this.begin;
    }

    public Value end() {
        return this.end;
    }

    public static enum Type {
        BOUNDARY,
        EXHAUSTIVELY;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy