public boolean check(String range) {
        if (range == null || range.isEmpty()) {
            return false;
        }

        boolean result = false;
        StringBuilder builder = new StringBuilder();
        for (int i = 0, len = range.length(); i < len; i++) {
            char ch = range.charAt(i);
            if ((ch >= '0' && ch <= '9') || ch == '.') {
                builder.append(ch);
            } else if (ch == '[' || ch == '(') {
                if (builder.length() > 0) {
                    throw new IllegalArgumentException(String.format(Locale.ROOT,
                            "Expect a comma after %s at %d but got %s", builder.toString(), i, ch));
                }

                ClickHouseVersionUtils v1 = null;
                ClickHouseVersionUtils v2 = null;

                char nextCh = '\0';
                for (i = i + 1; i < len; i++) {
                    nextCh = range.charAt(i);
                    if ((nextCh >= '0' && nextCh <= '9') || nextCh == '.') {
                        builder.append(nextCh);
                    } else if (nextCh == ',') {
                        v1 = ClickHouseVersionUtils.of(builder.toString());
                        builder.setLength(0);
                    } else if (nextCh == ')' || nextCh == ']') {
                        if (builder.length() == 0) {
                            v2 = latestVersion;
                        } else {
                            v2 = ClickHouseVersionUtils.of(builder.toString());
                            builder.setLength(0);
                        }
                        break;
                    }
                }

                if (v1 == null || v2 == null) {
                    throw new IllegalArgumentException(
                            "Brackets must come in pairs and at least one version and a comma must be specified within brackets");
                }

                result = ch == '(' ? isNewerThan(v1) : isNewerOrEqualTo(v1);
                if (!result) {
                    break;
                }

                result = nextCh == ')' ? (latest || isOlderThan(v2)) : isOlderOrEqualTo(v2);
                if (!result) {
                    break;
                }
            } else if (ch == ',' && builder.length() > 0) {
                ClickHouseVersionUtils v = of(builder.toString());
                builder.setLength(0);

                result = belongsTo(v);
                if (!result) {
                    break;
                }
            }
        }

        if (builder.length() > 0) {
            result = belongsTo(builder.toString());
        }

        return result;
    }
Checks if the version is valid according to the given maven-like version
range.

@param range version range, null or empty string means always invalid
@return true if the version is valid; false otherwise
clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseVersionUtils.java