本文整理汇总了Java中com.github.zafarkhaja.semver.Version.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java Version.compareTo方法的具体用法?Java Version.compareTo怎么用?Java Version.compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.zafarkhaja.semver.Version
的用法示例。
在下文中一共展示了Version.compareTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@Override
public void run () {
boolean isOutdated = false;
Release latestRelease = null;
try {
String releasesText = sendRequest("repos/" + REPO + "/releases");
if (releasesText != null) {
JSONArray releases = new JSONArray(releasesText);
if (releases.length() > 0) {
for (int index = 0; index < releases.length(); index++) {
Release release = Release.from(releases.getJSONObject(index));
if ( ! release.isPreRelease()) {
Version releaseVersion = Version.valueOf(release.getVersion());
if (releaseVersion.compareTo(version) > 0) {
isOutdated = true;
latestRelease = release;
}
break;
}
}
}
}
} catch (Exception err) {
bugsnag.notify(err);
} finally {
this.isOutdated = isOutdated;
this.latestRelease = latestRelease;
}
}
示例2: compare
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@Override
public int compare(HybridMobileEngine o1, HybridMobileEngine o2) {
try {
Version version1 = Version.valueOf(o1.getSpec());
Version version2 = Version.valueOf(o2.getSpec());
if (descending) {
return version2.compareTo(version1);
}
return version1.compareTo(version2);
} catch (Exception e) {
return 1;
}
}
示例3: compare
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@Override
public int compare(DownloadableCordovaEngine o1, DownloadableCordovaEngine o2) {
Version v1 = Version.valueOf(o1.getVersion());
Version v2 = Version.valueOf(o2.getVersion());
//Make it descending switch v1 to v2
return v2.compareTo(v1);
}
示例4: dbNeedsMigration
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
/**
*
* @return {@code true} if there is <b>nothing</b> to do.
*/
public boolean dbNeedsMigration()
{
final Version dbVersion = Version.valueOf(dbVersionStr);
logger.info("AD_System.DBVersion is {}", dbVersion);
final Version rolloutVersion = Version.valueOf(rolloutVersionStr);
logger.info("Our own version is {}", rolloutVersion);
final int comp = dbVersion.compareTo(rolloutVersion);
if (comp == 0)
{
logger.info("AD_System.DBVersion is equal to our version. Nothing to do.");
return false;
}
else if (comp < 0)
{
// dbVersion is lower than rolloutVersion
// => we need to do the migration to "elevate" it
logger.info("The DB version is lower than our own version. Going to migrate");
return true;
}
// Check if we have the special case of issue https://github.com/metasfresh/metasfresh/issues/2260
final boolean sameMajorVersion = dbVersion.getMajorVersion() == rolloutVersion.getMajorVersion();
final boolean sameMinorVersion = dbVersion.getMinorVersion() == rolloutVersion.getMinorVersion();
final boolean patchVersionSwitchBetweenOneAndTwo = //
dbVersion.getPatchVersion() == 1 && rolloutVersion.getPatchVersion() == 2 //
|| dbVersion.getPatchVersion() == 2 && rolloutVersion.getPatchVersion() == 1;
if (sameMajorVersion
&& sameMinorVersion
&& patchVersionSwitchBetweenOneAndTwo)
{
logger.info("Detected a version switch between master (=> patchVersion=1) and release, issue etc (=> patchVersion=2). Assuming that the DB needs migration. Also see https://github.com/metasfresh/metasfresh/issues/2260");
return true;
}
// check if we have a switch between two non-master branches
if(!Objects.equals(dbVersion.getBuildMetadata(), rolloutVersion.getBuildMetadata()))
{
logger.info("Detected a version switch between \"branches\" dbVersion={} and rolloutVersion={}. Assuming that the DB needs migration. Also see https://github.com/metasfresh/metasfresh/issues/2260",
dbVersion.getPreReleaseVersion(), rolloutVersion.getPreReleaseVersion());
return true;
}
// Issue https://github.com/metasfresh/metasfresh/issues/2260 does not apply..
// dbVersion higher....uh-ooh
final String msg = "The code has version " + rolloutVersionStr + " but the DB already has version " + dbVersionStr;
if (!failIfRolloutIsGreaterThanDB)
{
// let's ignore the problem
logger.info(msg + ". *Not* throwing exception because of the +" + CommandlineParams.OPTION_DoNotFailIfRolloutIsGreaterThanDB + " parameter; but not going to attempt migration either.");
return false;
}
throw new InconsistentVersionsException(msg);
}
示例5: compare
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@Override
public int compare(DownloadableCordovaEngine o1, DownloadableCordovaEngine o2) {
Version v1 = Version.valueOf(o1.getVersion());
Version v2 = Version.valueOf(o2.getVersion());
return v2.compareTo(v1);
}
示例6: compare
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@Override
public int compare(String o1, String o2) {
Version v1 = LaravelVersion.fromString(o1);
Version v2 = LaravelVersion.fromString(o2);
return _isNewestFirst ? v2.compareTo(v1) : v1.compareTo(v2);
}