本文整理了Java中org.sonar.api.utils.Version.compareTo()
方法的一些代码示例,展示了Version.compareTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.compareTo()
方法的具体详情如下:
包路径:org.sonar.api.utils.Version
类名称:Version
方法名:compareTo
暂无
代码示例来源:origin: SonarSource/sonarqube
public boolean isGreaterThanOrEqual(Version than) {
return this.compareTo(than) >= 0;
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void init(DatabaseMetaData metaData) throws SQLException {
checkState(!initialized, "onInit() must be called once");
Version version = checkDbVersion(metaData, MIN_SUPPORTED_VERSION);
supportsUpsert = version.compareTo(MIN_UPSERT_VERSION) >= 0;
if (!supportsUpsert) {
Loggers.get(getClass()).warn("Upgrading PostgreSQL to {} or greater is recommended for better performances", MIN_UPSERT_VERSION);
}
initialized = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
Version checkDbVersion(DatabaseMetaData metaData, Version minSupported) throws SQLException {
int major = metaData.getDatabaseMajorVersion();
int minor = metaData.getDatabaseMinorVersion();
Version version = Version.create(major, minor, 0);
if (version.compareTo(minSupported) < 0) {
throw MessageException.of(String.format(
"Unsupported %s version: %s. Minimal supported version is %s.", getId(), version, minSupported));
}
return version;
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void test_compareTo() {
assertThat(parse("1.2").compareTo(parse("1.2.0"))).isEqualTo(0);
assertThat(parse("1.2.3").compareTo(parse("1.2.3"))).isEqualTo(0);
assertThat(parse("1.2.3").compareTo(parse("1.2.4"))).isLessThan(0);
assertThat(parse("1.2.3").compareTo(parse("1.3"))).isLessThan(0);
assertThat(parse("1.2.3").compareTo(parse("2.1"))).isLessThan(0);
assertThat(parse("1.2.3").compareTo(parse("2.0.0"))).isLessThan(0);
assertThat(parse("2.0").compareTo(parse("1.2"))).isGreaterThan(0);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void compareTo_handles_build_number() {
assertThat(parse("1.2").compareTo(parse("1.2.0.0"))).isEqualTo(0);
assertThat(parse("1.2.3.1234").compareTo(parse("1.2.3.4567"))).isLessThan(0);
assertThat(parse("1.2.3.1234").compareTo(parse("1.2.3"))).isGreaterThan(0);
assertThat(parse("1.2.3.1234").compareTo(parse("1.2.4"))).isLessThan(0);
assertThat(parse("1.2.3.9999").compareTo(parse("1.2.4.1111"))).isLessThan(0);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void qualifier_is_ignored_from_comparison() {
assertThat(parse("1.2.3")).isEqualTo(parse("1.2.3-build1"));
assertThat(parse("1.2.3")).isEqualTo(parse("1.2.3-build1"));
assertThat(parse("1.2.3").compareTo(parse("1.2.3-build1"))).isEqualTo(0);
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
public boolean isGreaterThanOrEqual(Version than) {
return this.compareTo(than) >= 0;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-db-core
@Override
public void init(DatabaseMetaData metaData) throws SQLException {
checkState(!initialized, "onInit() must be called once");
Version version = checkDbVersion(metaData, MIN_SUPPORTED_VERSION);
supportsUpsert = version.compareTo(MIN_UPSERT_VERSION) >= 0;
if (!supportsUpsert) {
Loggers.get(getClass()).warn("Upgrading PostgreSQL to {} or greater is recommended for better performances", MIN_UPSERT_VERSION);
}
initialized = true;
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-db-core
Version checkDbVersion(DatabaseMetaData metaData, Version minSupported) throws SQLException {
int major = metaData.getDatabaseMajorVersion();
int minor = metaData.getDatabaseMinorVersion();
Version version = Version.create(major, minor, 0);
if (version.compareTo(minSupported) < 0) {
throw MessageException.of(String.format(
"Unsupported %s version: %s. Minimal supported version is %s.", getId(), version, minSupported));
}
return version;
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-db
private void checkMinDatabaseVersion() throws SQLException {
Version minDbVersion = MINIMAL_SUPPORTED_DB_VERSIONS.get(db.getDialect().getId());
if (minDbVersion != null) {
try (Connection connection = db.getDataSource().getConnection()) {
int dbMajorVersion = connection.getMetaData().getDatabaseMajorVersion();
int dbMinorVersion = connection.getMetaData().getDatabaseMinorVersion();
Version dbVersion = Version.create(dbMajorVersion, dbMinorVersion, 0);
if (dbVersion.compareTo(minDbVersion) < 0) {
throw MessageException.of(String.format(
"Unsupported %s version: %s. Minimal supported version is %s.", db.getDialect().getId(), dbVersion, minDbVersion));
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!