本文整理了Java中com.github.zafarkhaja.semver.Version
类的一些代码示例,展示了Version
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version
类的具体详情如下:
包路径:com.github.zafarkhaja.semver.Version
类名称:Version
[英]The Version class is the main class of the Java SemVer library. This class implements the Facade design pattern. It is also immutable, which makes the class thread-safe.
[中]Version类是Java SemVer库的主类。此类实现了Facade设计模式。它也是不可变的,这使得类线程安全。
代码示例来源:origin: Graylog2/graylog2-server
versionProperties.load(resource.openStream());
final com.github.zafarkhaja.semver.Version version = com.github.zafarkhaja.semver.Version.valueOf(versionProperties.getProperty(propertyName));
final int major = version.getMajorVersion();
final int minor = version.getMinorVersion();
final int patch = version.getPatchVersion();
final String qualifier = version.getPreReleaseVersion();
代码示例来源:origin: Graylog2/graylog2-server
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return version.toString();
}
代码示例来源:origin: cSploit/android
/**
* is version {@code a} newer than {@code b} ?
*/
private boolean isNewerThan(String a, String b) {
return Version.valueOf(a).compareTo(Version.valueOf(b)) > 0;
}
代码示例来源:origin: Graylog2/graylog2-server
public Version(com.github.zafarkhaja.semver.Version version) {
this.version = requireNonNull(version);
// Deprecated
this.major = version.getMajorVersion();
this.minor = version.getMinorVersion();
this.patch = version.getPatchVersion();
this.additional = version.getPreReleaseVersion();
this.abbrevCommitSha = version.getBuildMetadata();
}
代码示例来源:origin: Graylog2/graylog2-server
private static com.github.zafarkhaja.semver.Version buildSemVer(int major, int minor, int patch, String preRelease, String buildMetadata) {
com.github.zafarkhaja.semver.Version version = com.github.zafarkhaja.semver.Version.forIntegers(major, minor, patch);
if (!isNullOrEmpty(preRelease)) {
version = version.setPreReleaseVersion(preRelease);
}
if (!isNullOrEmpty(buildMetadata)) {
version = version.setBuildMetadata(buildMetadata);
}
return version;
}
代码示例来源:origin: org.kurento/kurento-module-creator
private static String processCaretRanges(String version) {
if (version.startsWith("^")) {
String plainVersion = version.substring(1);
return ">=" + plainVersion + " & <" + (Version.valueOf(plainVersion).getMajorVersion() + 1)
+ ".0.0";
}
return version;
}
代码示例来源:origin: syncany/syncany
private UpdateOperationResult executeCheck() throws Exception {
Version localAppVersion = Version.valueOf(Client.getApplicationVersion());
String appInfoResponseStr = getAppInfoResponseStr();
AppInfoResponse appInfoResponse = new Persister().read(AppInfoResponse.class, appInfoResponseStr);
ArrayList<AppInfo> appInfoList = appInfoResponse.getAppInfoList();
if (appInfoList.size() > 0) {
AppInfo remoteAppInfo = appInfoList.get(0);
Version remoteAppVersion = Version.valueOf(remoteAppInfo.getAppVersion());
boolean newVersionAvailable = remoteAppVersion.greaterThan(localAppVersion);
result.setResultCode(UpdateResultCode.OK);
result.setAppInfo(remoteAppInfo);
result.setNewVersionAvailable(newVersionAvailable);
return result;
}
else {
result.setResultCode(UpdateResultCode.NOK);
return result;
}
}
代码示例来源:origin: Graylog2/graylog2-server
/**
* @see com.github.zafarkhaja.semver.Version#greaterThanOrEqualTo(com.github.zafarkhaja.semver.Version)
*/
public boolean sameOrHigher(Version other) {
if (isNullOrEmpty(version.getPreReleaseVersion())) {
return version.greaterThanOrEqualTo(other.getVersion());
} else {
// If this is a pre-release version, use the major.minor.patch version for comparison with the other.
// This allows plugins to require a server version of 2.1.0 and it still gets loaded on a 2.1.0-beta.2 server.
// See: https://github.com/Graylog2/graylog2-server/issues/2462
return com.github.zafarkhaja.semver.Version.valueOf(version.getNormalVersion()).greaterThanOrEqualTo(other.getVersion());
}
}
代码示例来源:origin: Graylog2/graylog2-server
private Version parseVersion(String version) {
try {
return Version.valueOf(version);
} catch (Exception e) {
throw new ElasticsearchException("Unable to parse Elasticsearch version: " + version, e);
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public Version deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
switch (p.getCurrentTokenId()) {
case JsonTokenId.ID_STRING:
final String str = p.getText().trim();
return Version.valueOf(str);
case JsonTokenId.ID_NUMBER_INT:
return Version.forIntegers(p.getIntValue());
}
throw ctxt.wrongTokenException(p, JsonToken.VALUE_STRING, "expected String or Number");
}
}
代码示例来源:origin: syncany/syncany
private PluginOperationResult executeList() throws Exception {
final Version applicationVersion = Version.valueOf(Client.getApplicationVersion());
Map<String, ExtendedPluginInfo> pluginInfos = new TreeMap<String, ExtendedPluginInfo>();
extendedPluginInfo.setRemoteAvailable(true);
Version localVersion = Version.valueOf(extendedPluginInfo.getLocalPluginInfo().getPluginVersion());
Version remoteVersion = Version.valueOf(remotePluginInfo.getPluginVersion());
Version remoteMinAppVersion = Version.valueOf(remotePluginInfo.getPluginAppMinVersion());
boolean localVersionOutdated = localVersion.lessThan(remoteVersion);
boolean applicationVersionCompatible = applicationVersion.greaterThanOrEqualTo(remoteMinAppVersion);
boolean pluginIsOutdated = localVersionOutdated && applicationVersionCompatible;
代码示例来源:origin: gradle.plugin.br.com.sabium/gradle-bump
public String nextPreReleaseVersion(final String releaseTag, final String releaseTagPattern) {
if (releaseTag.matches(releaseTagPattern)) {
final Pattern pattern = Pattern.compile(releaseTagPattern);
final Matcher m = pattern.matcher(releaseTag);
m.matches();
Version v = Version.valueOf(m.group(0));
if (!m.group(2).contains("-")) {
v = v.incrementPatchVersion().setPreReleaseVersion("rc").incrementPreReleaseVersion();
} else {
v = v.incrementPreReleaseVersion();
}
return v.toString();
}
return StringUtils.EMPTY;
}
代码示例来源:origin: syncany/syncany
private void checkPluginCompatibility(PluginInfo pluginInfo) throws Exception {
Version applicationVersion = Version.valueOf(Client.getApplicationVersion());
Version pluginAppMinVersion = Version.valueOf(pluginInfo.getPluginAppMinVersion());
logger.log(Level.INFO, "Checking plugin compatibility:");
logger.log(Level.INFO, "- Application version: " + Client.getApplicationVersion() + "(" + applicationVersion + ")");
logger.log(Level.INFO, "- Plugin min. application version: " + pluginInfo.getPluginAppMinVersion() + "(" + pluginAppMinVersion + ")");
if (applicationVersion.lessThan(pluginAppMinVersion)) {
throw new Exception("Plugin is incompatible to this application version. Plugin min. application version is "
+ pluginInfo.getPluginAppMinVersion() + ", current application version is " + Client.getApplicationVersion());
}
// Verify if any conflicting plugins are installed
logger.log(Level.INFO, "Checking for conflicting plugins.");
List<String> conflictingIds = pluginInfo.getConflictingPluginIds();
List<String> conflictingInstalledIds = new ArrayList<String>();
if (conflictingIds != null) {
for (String pluginId : conflictingIds) {
Plugin plugin = Plugins.get(pluginId);
if (plugin != null) {
logger.log(Level.INFO, "- Conflicting plugin " + pluginId + " found.");
conflictingInstalledIds.add(pluginId);
}
logger.log(Level.FINE, "- Conflicting plugin " + pluginId + " not installed");
}
}
result.setConflictingPlugins(conflictingInstalledIds);
}
代码示例来源:origin: gradle.plugin.br.com.sabium/gradle-bump
public String nextSnapshotVersion(final String tag, final String tagPattern) {
Version v;
if (tag.matches(tagPattern)) {
final Pattern pattern = Pattern.compile(tagPattern);
final Matcher m = pattern.matcher(tag);
m.matches();
v = Version.valueOf(m.group(1)).incrementMinorVersion();
return v.toString();
}
return StringUtils.EMPTY;
}
代码示例来源:origin: gradle.plugin.br.com.sabium/gradle-bump
public String nextReleaseVersion(final String tag, final String tagPattern) {
Version v;
if (tag.matches(tagPattern)) {
final Pattern pattern = Pattern.compile(tagPattern);
final Matcher m = pattern.matcher(tag);
m.matches();
if (m.group(2).contains("-")) {
v = Version.valueOf(m.group(1));
} else {
v = Version.valueOf(m.group(1)).incrementPatchVersion();
}
return v.toString();
}
return StringUtils.EMPTY;
}
代码示例来源:origin: Microsoft/azure-maven-plugins
protected void assureRequirementAddressed() throws Exception {
final String localVersion = getLocalFunctionCoreToolsVersion();
final String latestCoreVersion = getLatestFunctionCoreToolsVersion();
// Ensure azure function core tools has been installed and support extension auto-install
if (localVersion == null || LEAST_SUPPORTED_VERSION.greaterThan(Version.valueOf(localVersion))) {
throw new Exception(CANNOT_AUTO_INSTALL);
}
// Verify whether local function core tools is the latest version
if (latestCoreVersion == null) {
this.mojo.warning(GET_LATEST_VERSION_FAIL);
} else if (Version.valueOf(localVersion).lessThan(Version.valueOf(latestCoreVersion))) {
this.mojo.warning(String.format(NEED_UPDATE_FUNCTION_CORE_TOOLS, localVersion, latestCoreVersion));
}
}
代码示例来源:origin: infiniteautomation/ma-core-public
public static final Version normalizeVersion(Version version) {
return Version.forIntegers(version.getMajorVersion(), version.getMinorVersion(), version.getPatchVersion());
}
代码示例来源:origin: pf4j/pf4j
/**
* Checks if a version satisfies the specified SemVer {@link Expression} string.
* If the constraint is empty or null then the method returns true.
* Constraint examples: {@code >2.0.0} (simple), {@code ">=1.4.0 & <1.6.0"} (range).
* See https://github.com/zafarkhaja/jsemver#semver-expressions-api-ranges for more info.
*
* @param version
* @param constraint
* @return
*/
@Override
public boolean checkVersionConstraint(String version, String constraint) {
return StringUtils.isNullOrEmpty(constraint) || Version.valueOf(version).satisfies(constraint);
}
代码示例来源:origin: Graylog2/graylog2-server
/**
* {@inheritDoc}
*/
@Override
public int compareTo(@Nonnull Version that) {
requireNonNull(that);
return version.compareTo(that.getVersion());
}
}
代码示例来源:origin: Graylog2/graylog2-server
@Override
public String toString() {
final com.github.zafarkhaja.semver.Version version = Version.CURRENT_CLASSPATH.getVersion();
final String shortVersion = version.getMajorVersion() + "." + version.getMinorVersion();
return DOCS_URL + shortVersion + "/pages/" + path;
}
内容来源于网络,如有侵权,请联系作者删除!