class PgIntRange {

    public static Range parse(String s) {
        Matcher m = PATTERN.matcher(s);
        if (!m.matches()) {
            throw new IllegalArgumentException("Invalid range value: " + s);
        }

        Range.Mode lowerMode = parseMode(m.group(1));
        int lower = Integer.parseInt(m.group(2));
        int upper = Integer.parseInt(m.group(3));
        Range.Mode upperMode = parseMode(m.group(4));

        return Range.builder()
                .lowerMode(lowerMode)
                .lower(lower)
                .upper(upper)
                .upperMode(upperMode)
                .build();
    }

    private  PgIntRange();

}