本文整理汇总了Java中com.github.zafarkhaja.semver.Version.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Version.valueOf方法的具体用法?Java Version.valueOf怎么用?Java Version.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.zafarkhaja.semver.Version
的用法示例。
在下文中一共展示了Version.valueOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateUploadRequest
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
private void validateUploadRequest(UploadRequest uploadRequest) {
Assert.notNull(uploadRequest.getRepoName(), "Repo name can not be null");
Assert.notNull(uploadRequest.getName(), "Name of package can not be null");
Assert.notNull(uploadRequest.getVersion(), "Version can not be null");
try {
Version.valueOf(uploadRequest.getVersion().trim());
}
catch (ParseException e) {
throw new SkipperException("UploadRequest doesn't have a valid semantic version. Version = " +
uploadRequest.getVersion().trim());
}
Assert.notNull(uploadRequest.getExtension(), "Extension can not be null");
Assert.isTrue(uploadRequest.getExtension().equals("zip"), "Extension must be 'zip', not "
+ uploadRequest.getExtension());
Assert.notNull(uploadRequest.getPackageFileAsBytes(), "Package file as bytes must not be null");
Assert.isTrue(uploadRequest.getPackageFileAsBytes().length != 0, "Package file as bytes must not be empty");
PackageMetadata existingPackageMetadata = this.packageMetadataRepository.findByRepositoryNameAndNameAndVersion(
uploadRequest.getRepoName().trim(), uploadRequest.getName().trim(), uploadRequest.getVersion().trim());
if (existingPackageMetadata != null) {
throw new SkipperException(String.format("Failed to upload the package. " + "" +
"Package [%s:%s] in Repository [%s] already exists.",
uploadRequest.getName(), uploadRequest.getVersion(), uploadRequest.getRepoName().trim()));
} }
示例2: main
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
public static void main(String[] args) {
Locale.setDefault(Locale.US);
org.apache.log4j.BasicConfigurator.configure();
try {
Properties properties = new Properties();
InputStream stream = Application.class.getResourceAsStream("application.properties");
properties.load(stream);
stream.close();
version = Version.valueOf(properties.getProperty("version"));
} catch (IOException e) {
e.printStackTrace();
}
launch(args);
}
示例3: parseVersion
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
public static String parseVersion(String version) {
if (!version.startsWith("(") && !version.startsWith("[")) {
// first see if it actually is a range
try {
Version.valueOf(version);
}
catch (Exception e) {
// remove ^ for wildcard ranges
if ((version.startsWith("^") || version.startsWith("||")) && (version.contains("x")
|| version.contains("X") || version.contains("*"))) {
version = version.substring(1);
}
try {
version = ExpressionParser.newInstance().parse(version).mavenRange();
}
catch (Exception ex) {
throw new ManifestParsingException("Unable to parse version range %s.",
version);
}
}
}
return version;
}
示例4: versionNameConditionMet
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
private boolean versionNameConditionMet(final String versionName, final Element element) {
// Drop out quickly if there's no versionName set otherwise the try/catch below is doomed to fail.
if (versionName.isEmpty()) return false;
int comparison;
try {
final Version conditionVersion = Version.valueOf(versionName);
final Version currentVersion = Version.valueOf(this.versionName);
comparison = Version.BUILD_AWARE_ORDER.compare(conditionVersion, currentVersion);
} catch (final IllegalArgumentException | com.github.zafarkhaja.semver.ParseException e) {
messager.printMessage(Diagnostic.Kind.ERROR, String.format("Failed to parse versionName: %1$s. " +
"Please use a versionName that matches the specification on http://semver.org/", versionName),
element);
// Assume the break condition is met if the versionName is invalid.
return true;
}
return !versionName.isEmpty() && comparison <= 0;
}
示例5: createVersionWithOptionalSuffix
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@VisibleForTesting
static String createVersionWithOptionalSuffix(
@NonNull final String versionStr,
final String suffix)
{
final Version version;
if (suffix == null || "".equals(suffix) || versionStr.endsWith(suffix))
{
// there is no suffix, or the same suffix was already added earlier when a migration was not completed
version = Version.valueOf(versionStr);
}
else
{
final Version tmp = Version.valueOf(versionStr);
version = tmp.setBuildMetadata(tmp.getBuildMetadata() + "x" + suffix);
}
return version.toString();
}
示例6: isDefinitionSatisfied
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
private IStatus isDefinitionSatisfied(EngineDefinition definition, HybridMobileEngine engine) {
String reason;
if (engine.getName().equals(definition.name)) {// Engine ids match
Version engineVer = Version.valueOf(engine.getSpec());
if (engineVer.satisfies(definition.version)) { // version is satisfied
return Status.OK_STATUS;
} else {
reason = "engine version: " + definition.version;
}
} else {
reason = "engine id: " + definition.name;
}
return new Status(IStatus.WARNING, HybridCore.PLUGIN_ID,
NLS.bind("Plug-in {0} does not support {1} version {2}. Fails version requirement: {3}",
new Object[] { getLabel(), engine.getName(), engine.getSpec(), reason }));
}
示例7: populateVersionsList
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
private void populateVersionsList(){
JSONObject versions = feedObject.getJSONObject("versions");
Iterator keysIterator = versions.keys();
versionsList = new ArrayList<Version>();
versionStringMap = new HashMap<Version, String>() ;
while (keysIterator.hasNext()) {
String versionString = (String)keysIterator.next();
Version currentVersion = Version.valueOf(versionString);
if(isWithinBounds(currentVersion)) {
versionStringMap.put(currentVersion, versionString);
versionsList.add(currentVersion);
}
}
Collections.sort(versionsList, Collections.reverseOrder());
}
示例8: status
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
@Test
public void status() throws Exception {
List<DependencyStatus> deps = ws.status();
assertThat("incorrect number of dependencies", deps.size(), is(2));
DependencyStatus mwdb = deps.get(0);
assertThat("incorrect fail", mwdb.isOk(), is(true));
assertThat("incorrect name", mwdb.getName(), is("MongoDB"));
assertThat("incorrect status", mwdb.getStatus(), is("OK"));
//should throw an error if not a semantic version
Version.valueOf(mwdb.getVersion());
DependencyStatus blob = deps.get(1);
assertThat("incorrect fail", blob.isOk(), is(true));
String n = blob.getName();
assertThat("incorrect name", n.equals("Shock") || n.equals("GridFS"),
is(true));
assertThat("incorrect status", blob.getStatus(), is("OK"));
//should throw an error if not a semantic version
Version.valueOf(blob.getVersion());
}
示例9: readFileVersion
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
public static Version readFileVersion(Path target) throws IOException {
final byte[] data = ZipUtil.unpackEntry(target.toFile(), PROJECT_VERSION_FILENAME);
if (data == null) {
// Best guess, since the actual version information is hidden inside the JSON
return Version.forIntegers(0, 2, 2);
} else {
InputStream stream = new ByteArrayInputStream(data);
return Version.valueOf(IOUtils.toString(stream, Charset.forName("UTF-8")));
}
}
示例10: getReport
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
private static ReleaseReport getReport(ReleaseResponse response) {
String githubVersion = extractVersion(response);
Version build = Version.valueOf(SteveConfiguration.CONFIG.getSteveVersion());
Version github = Version.valueOf(githubVersion);
boolean isGithubMoreRecent = github.greaterThan(build);
String downloadUrl = decideDownloadUrl(response);
ReleaseReport ur = new ReleaseReport(isGithubMoreRecent);
ur.setGithubVersion(githubVersion);
ur.setDownloadUrl(downloadUrl);
ur.setHtmlUrl(response.getHtmlUrl());
return ur;
}
示例11: toVersion
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
private Version toVersion(String version) {
StringBuilder semVer = new StringBuilder(version);
for (int i = 0; i < 2 - version.replaceAll("[^.]", "").length(); i++) {
semVer.append(".0");
}
return Version.valueOf(semVer.toString());
}
开发者ID:Enterprise-Content-Management,项目名称:infoarchive-sip-sdk,代码行数:8,代码来源:ApplicationIngestionResourcesCache.java
示例12: setVersion
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
public void setVersion(@NonNull String version) {
try {
this.version = Version.valueOf(version);
} catch (UnexpectedCharacterException e) {
this.version = null;
Log.e(TAG, "Failed to parse version: " + version, e);
}
}
示例13: filter
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
/**
* From the given set of available broker candidates, filter those using the version numbers.
*
* @param brokers
* The currently available brokers that have not already been filtered.
* @param bundleToAssign
* The data for the bundle to assign.
* @param loadData
* The load data from the leader broker.
* @param conf
* The service configuration.
*/
public void filter(Set<String> brokers, BundleData bundleToAssign, LoadData loadData, ServiceConfiguration conf)
throws BrokerFilterBadVersionException {
if ( !conf.isPreferLaterVersions()) {
return;
}
com.github.zafarkhaja.semver.Version latestVersion = null;
try {
latestVersion = getLatestVersionNumber(brokers, loadData);
LOG.info("Latest broker version found was [{}]", latestVersion);
} catch ( Exception x ) {
LOG.warn("Disabling PreferLaterVersions feature; reason: " + x.getMessage());
throw new BrokerFilterBadVersionException("Cannot determine newest broker version: " + x.getMessage());
}
int numBrokersLatestVersion=0;
int numBrokersOlderVersion=0;
Iterator<String> brokerIterator = brokers.iterator();
while ( brokerIterator.hasNext() ) {
String broker = brokerIterator.next();
BrokerData data = loadData.getBrokerData().get(broker);
String brokerVersion = data.getLocalData().getBrokerVersionString();
com.github.zafarkhaja.semver.Version brokerVersionVersion = Version.valueOf(brokerVersion);
if ( brokerVersionVersion.equals(latestVersion) ) {
LOG.debug("Broker [{}] is running the latest version ([{}])", broker, brokerVersion);
++numBrokersLatestVersion;
} else {
LOG.info("Broker [{}] is running an older version ([{}]); latest version is [{}]", broker, brokerVersion, latestVersion);
++numBrokersOlderVersion;
brokerIterator.remove();
}
}
if ( numBrokersOlderVersion == 0 ) {
LOG.info("All {} brokers are running the latest version [{}]", numBrokersLatestVersion, latestVersion);
}
}
示例14: 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;
}
}
示例15: parseFromDockerComposeVersion
import com.github.zafarkhaja.semver.Version; //导入方法依赖的package包/类
public static Version parseFromDockerComposeVersion(String versionOutput) {
String[] splitOnSeparator = versionOutput.split(" ");
String version = splitOnSeparator[2];
StringBuilder builder = new StringBuilder();
for (int i = 0; i < version.length(); i++) {
if (version.charAt(i) >= '0' && version.charAt(i) <= '9' || version.charAt(i) == '.') {
builder.append(version.charAt(i));
} else {
return Version.valueOf(builder.toString());
}
}
return Version.valueOf(builder.toString());
}