@NotNull
  private String selectVersion(@NotNull MavenId mavenId,
                               @Nullable String minVersion,
                               @Nullable String maxVersion,
                               @Nullable String preferredVersion) {
    Set<String> versions = (mavenId.getGroupId() == null || mavenId.getArtifactId() == null)
                           ? Collections.emptySet()
                           : DependencySearchService.getInstance(myProject).getVersions(mavenId.getGroupId(), mavenId.getArtifactId());
    if (preferredVersion != null && versions.contains(preferredVersion)) {
      return preferredVersion;
    }
    List<String> suitableVersions = new ArrayList<>();
    for (String version : versions) {
      if ((minVersion == null || VersionComparatorUtil.compare(minVersion, version) <= 0)
          && (maxVersion == null || VersionComparatorUtil.compare(version, maxVersion) <= 0)) {
        suitableVersions.add(version);
      }
    }
    if (suitableVersions.isEmpty()) {
      return mavenId.getVersion() == null ? "RELEASE" : mavenId.getVersion();
    }
    return Collections.max(suitableVersions, VersionComparatorUtil.COMPARATOR);
  }
@NotNull
  private String selectVersion(@NotNull MavenId mavenId,
                               @Nullable String minVersion,
                               @Nullable String maxVersion,
                               @Nullable String preferredVersion)