public static VersionRange parse(String rangeString) {
    validateRangeString(rangeString);

    Inclusiveness minVersionInclusiveness =
        rangeString.startsWith("[") ? Inclusiveness.INCLUSIVE : Inclusiveness.EXCLUSIVE;
    Inclusiveness maxVersionInclusiveness =
        rangeString.endsWith("]") ? Inclusiveness.INCLUSIVE : Inclusiveness.EXCLUSIVE;

    int commaIndex = rangeString.indexOf(',');

    String minVersionString = rangeString.substring(1, commaIndex).trim();
    Version minVersion;
    if (minVersionString.isEmpty()) {
      minVersionInclusiveness = Inclusiveness.EXCLUSIVE;
      minVersion = Version.minimum();
    } else {
      minVersion = Version.fromString(minVersionString);
    }

    String maxVersionString =
        rangeString.substring(commaIndex + 1, rangeString.length() - 1).trim();
    Version maxVersion;
    if (maxVersionString.isEmpty()) {
      maxVersionInclusiveness = Inclusiveness.EXCLUSIVE;
      maxVersion = Version.maximum();
    } else {
      maxVersion = Version.fromString(maxVersionString);
    }

    if (!minVersion.isLessThan(maxVersion)) {
      throw new IllegalArgumentException(
          String.format(
              "Min version in range must be less than max version in range, got '%s'",
              rangeString));
    }

    return builder()
        .setMinVersion(minVersion)
        .setMinVersionInclusiveness(minVersionInclusiveness)
        .setMaxVersion(maxVersion)
        .setMaxVersionInclusiveness(maxVersionInclusiveness)
        .build();
  }
@Test
  public void parse_withMinimalToMaximalRange_throwsIllegalArgumentException() {
    IllegalArgumentException exception =
        assertThrows(IllegalArgumentException.class, () -> VersionRange.parse("(,)"));
    assertThat(exception).hasMessageThat().isEqualTo("Infinity range is not supported, got '(,)'");
  }