public static VersionSet parse(ImmutableList<String> versionAndRangesList) {
    checkNotNull(versionAndRangesList);
    checkArgument(!versionAndRangesList.isEmpty(), "Versions and ranges list cannot be empty.");

    VersionSet.Builder versionSetBuilder = VersionSet.builder();

    for (String versionOrRangeString : versionAndRangesList) {
      if (isDiscreteVersion(versionOrRangeString)) {
        versionSetBuilder.addVersion(Version.fromString(versionOrRangeString));
      } else if (VersionRange.isValidVersionRange(versionOrRangeString)) {
        versionSetBuilder.addVersionRange(VersionRange.parse(versionOrRangeString));
      } else {
        throw new IllegalArgumentException(
            String.format(
                "String '%s' is neither a discrete string nor a version range.",
                versionOrRangeString));
      }
    }

    return versionSetBuilder.build();
  }
@Test
  public void parse_withInvalidVersion_throwsIllegalArgumentException() {
    IllegalArgumentException exception =
        assertThrows(
            IllegalArgumentException.class, () -> VersionSet.parse(ImmutableList.of("1,0", "abc")));
    assertThat(exception)
        .hasMessageThat()
        .isEqualTo("String '1,0' is neither a discrete string nor a version range.");
  }