本文整理了Java中com.github.zafarkhaja.semver.Version.valueOf()
方法的一些代码示例,展示了Version.valueOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.valueOf()
方法的具体详情如下:
包路径:com.github.zafarkhaja.semver.Version
类名称:Version
方法名:valueOf
[英]Creates a new instance of Version as a result of parsing the specified version string.
[中]通过分析指定的版本字符串,创建新的版本实例。
代码示例来源: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
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: 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();
代码示例来源: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: 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: 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: 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());
代码示例来源:origin: pf4j/pf4j
@Override
public int compareVersions(String v1, String v2) {
return Version.valueOf(v1).compareTo(Version.valueOf(v2));
}
代码示例来源: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: cinchapi/concourse
/**
* Construct a new instance.
*
* @param home
*/
@PackagePrivate
PluginContext(Path home, String pluginVersion, String concourseVersion) {
this.home = home;
this.pluginVersion = Version.valueOf(pluginVersion);
this.concourseVersion = Version.valueOf(concourseVersion);
}
代码示例来源:origin: lennartkoopmann/nzyme
public com.github.zafarkhaja.semver.Version getVersion() {
try {
Properties gitProperties = new Properties();
gitProperties.load(getClass().getClassLoader().getResourceAsStream("git.properties"));
return com.github.zafarkhaja.semver.Version.valueOf(String.valueOf(gitProperties.get("git.build.version")));
} catch(Exception e) {
// This is not recoverable and can only happen if something goes sideways during build.
throw new RuntimeException("Could not build semantic version from nzyme version.", e);
}
}
代码示例来源:origin: zafarkhaja/jsemver
/**
* Interprets the expression.
*
* @param version a {@code Version} string to interpret against
* @return the result of the expression interpretation
* @throws IllegalArgumentException if the input string is {@code NULL} or empty
* @throws ParseException when invalid version string is provided
* @throws UnexpectedCharacterException is a special case of {@code ParseException}
*/
public boolean interpret(String version) {
return interpret(Version.valueOf(version));
}
代码示例来源:origin: infinum/Android-Prince-of-Versions
@Override
public Version parse(String value) {
return new Version(com.github.zafarkhaja.semver.Version.valueOf(value));
}
}
代码示例来源:origin: org.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: com.bq.oss.corbel/rem-api
protected void checkVersion() {
String version = context.getEnvironment().getProperty("platform.version");
if (version != null) {
if (Version.valueOf(version).getMajorVersion() != Version.valueOf(this.version).getMajorVersion()) {
throw new InitializationRemException("Problem with rem init: current platform version is " + this.version
+ " but rem uses " + version);
}
}
}
代码示例来源:origin: io.corbel/rem-api
protected void checkVersion() {
String version = context.getEnvironment().getProperty("platform.version");
if (version != null) {
if (Version.valueOf(version).getMajorVersion() != Version.valueOf(this.version).getMajorVersion()) {
throw new InitializationRemException("Problem with rem init: current platform version is " + this.version
+ " but rem uses " + version);
}
}
}
代码示例来源:origin: palantir/docker-compose-rule
@Test
public void understand_old_version_format() throws IOException, InterruptedException {
when(executedProcess.getInputStream()).thenReturn(toInputStream("Docker version 1.7.2"));
Version version = docker.configuredVersion();
assertThat(version, is(Version.valueOf("1.7.2")));
}
代码示例来源:origin: palantir/docker-compose-rule
@Test
public void understand_new_version_format() throws IOException, InterruptedException {
when(executedProcess.getInputStream()).thenReturn(toInputStream("Docker version 17.03.1-ce"));
Version version = docker.configuredVersion();
assertThat(version, is(Version.valueOf("17.3.1")));
}
}
代码示例来源:origin: palantir/docker-compose-rule
@Test
public void remove_non_digits_when_passing_version_string() {
assertThat(
DockerComposeVersion.parseFromDockerComposeVersion("docker-compose version 1.7.0rc1, build 1ad8866"),
is(Version.valueOf("1.7.0")));
}
}
内容来源于网络,如有侵权,请联系作者删除!