private void appendToRange(final StringBuilder sb, final Version version) { final boolean hasMicro = version.getMicro() > 0; final boolean hasMinorOrMicro = version.getMinor() > 0 || hasMicro; sb.append(version.getMajor()); if (hasMinorOrMicro) { sb.append('.'); sb.append(version.getMinor()); if (hasMicro) { sb.append('.'); sb.append(version.getMicro()); } } }
private String deriveMavenVersion(BundleDescription bundle, final Version version) { final StringBuilder sb = new StringBuilder(); sb.append(version.getMajor()); sb.append('.'); sb.append(version.getMinor()); sb.append('.'); sb.append(version.getMicro()); final String qualifier = deriveMavenVersionQualifier(bundle, version); if (qualifier != null) { sb.append('-'); sb.append(qualifier); } return sb.toString(); }
private String deriveMavenVersionRange( @NotNull BundleDescription bundle, @NotNull Version recommendedVersion) { final String qualifier = deriveMavenVersionQualifier(bundle, recommendedVersion); final StringBuilder sb = new StringBuilder(); if (qualifier == null) { sb.append('['); appendToRange(sb, recommendedVersion); sb.append(",)"); } else { sb.append(recommendedVersion.getMajor()); sb.append('.'); sb.append(recommendedVersion.getMinor()); sb.append('.'); sb.append(recommendedVersion.getMicro()); sb.append('-'); sb.append(qualifier); } return sb.toString(); }