当前位置: 首页>>代码示例>>Java>>正文


Java Version.compareTo方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:jmshal,项目名称:meloooncensor,代码行数:36,代码来源:CheckForUpdatesTask.java

示例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;
	}
}
 
开发者ID:eclipse,项目名称:thym,代码行数:14,代码来源:AvailableCordovaEnginesSection.java

示例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);
}
 
开发者ID:eclipse,项目名称:thym,代码行数:8,代码来源:EngineAddDialog.java

示例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);
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:64,代码来源:VersionChecker.java

示例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);
}
 
开发者ID:eclipse,项目名称:thym,代码行数:7,代码来源:CordovaEngineProvider.java

示例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);
}
 
开发者ID:letrunghieu,项目名称:laravel-netbeans,代码行数:7,代码来源:LaravelVersionComparator.java


注:本文中的com.github.zafarkhaja.semver.Version.compareTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。