com.github.zafarkhaja.semver.Version.forIntegers()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(89)

本文整理了Java中com.github.zafarkhaja.semver.Version.forIntegers()方法的一些代码示例,展示了Version.forIntegers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.forIntegers()方法的具体详情如下:
包路径:com.github.zafarkhaja.semver.Version
类名称:Version
方法名:forIntegers

Version.forIntegers介绍

[英]Creates a new instance of Versionfor the specified version numbers.
[中]为指定的版本号创建新的version实例。

代码示例

代码示例来源:origin: Graylog2/graylog2-server

/**
 * Build valid {@link Version} from major, minor, and patch version ("X.Y.Z").
 *
 * @param major The major version component.
 * @param minor The minor version component.
 * @param patch The patch version component.
 * @return The {@link Version} instance built from the given parameters.
 */
public static Version from(int major, int minor, int patch) {
  return new Version(com.github.zafarkhaja.semver.Version.forIntegers(major, minor, patch));
}

代码示例来源: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: 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

final com.github.zafarkhaja.semver.Version reportedVersion = com.github.zafarkhaja.semver.Version.forIntegers(version.major, version.minor, version.patch);

代码示例来源:origin: Graylog2/graylog2-server

@Nullable
private Version getMongoVersion(DB adminDb) {
  final CommandResult buildInfoResult = adminDb.command("buildInfo");
  if (buildInfoResult.ok()) {
    final BasicDBList versionArray = (BasicDBList) buildInfoResult.get("versionArray");
    if (versionArray == null || versionArray.size() < 3) {
      LOG.debug("Couldn't retrieve MongoDB version");
      return null;
    }
    final int majorVersion = (int) versionArray.get(0);
    final int minorVersion = (int) versionArray.get(1);
    final int patchVersion = (int) versionArray.get(2);
    return Version.forIntegers(majorVersion, minorVersion, patchVersion);
  } else {
    LOG.debug("Couldn't retrieve MongoDB buildInfo: {}", buildInfoResult.getErrorMessage());
    return null;
  }
}

代码示例来源:origin: zafarkhaja/jsemver

/**
 * Creates a {@code Version} instance for the
 * specified major, minor and patch versions.
 *
 * @param major the major version number
 * @param minor the minor version number
 * @param patch the patch version number
 * @return the version for the specified major, minor and patch versions
 */
private Version versionFor(int major, int minor, int patch) {
  return Version.forIntegers(major, minor, patch);
}

代码示例来源:origin: com.github.zafarkhaja/java-semver

/**
 * Creates a {@code Version} instance for the
 * specified major, minor and patch versions.
 *
 * @param major the major version number
 * @param minor the minor version number
 * @param patch the patch version number
 * @return the version for the specified major, minor and patch versions
 */
private Version versionFor(int major, int minor, int patch) {
  return Version.forIntegers(major, minor, patch);
}

代码示例来源:origin: org.kurento/kurento-module-creator

/**
 * Creates a {@code Version} instance for the specified integers.
 *
 * @param major
 *          the major version number
 * @param minor
 *          the minor version number
 * @param patch
 *          the patch version number
 * @return the version for the specified integers
 */
private Version versionOf(int major, int minor, int patch) {
 return Version.forIntegers(major, minor, patch);
}

代码示例来源:origin: ro.fortsoft.pf4j/pf4j

public Version getVersion() {
  String version = null;
  Package pf4jPackage = PluginManager.class.getPackage();
  if (pf4jPackage != null) {
    version = pf4jPackage.getImplementationVersion();
    if (version == null) {
      version = pf4jPackage.getSpecificationVersion();
    }
  }
  return (version != null) ? Version.valueOf(version) : Version.forIntegers(0, 0, 0);
}

代码示例来源:origin: org.graylog2/graylog2-server

/**
 * Build valid {@link Version} from major, minor, and patch version ("X.Y.Z").
 *
 * @param major The major version component.
 * @param minor The minor version component.
 * @param patch The patch version component.
 * @return The {@link Version} instance built from the given parameters.
 */
public static Version from(int major, int minor, int patch) {
  return new Version(com.github.zafarkhaja.semver.Version.forIntegers(major, minor, patch));
}

代码示例来源:origin: palantir/docker-compose-rule

public Version configuredVersion() throws IOException, InterruptedException {
  String versionString = command.execute(Command.throwingOnError(), "-v");
  Matcher matcher = VERSION_PATTERN.matcher(versionString);
  checkState(matcher.matches(), "Unexpected output of docker -v: %s", versionString);
  return Version.forIntegers(Integer.parseInt(matcher.group(1)),
                Integer.parseInt(matcher.group(2)),
                Integer.parseInt(matcher.group(3)));
}

代码示例来源:origin: org.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: ro.fortsoft.pf4j/pf4j-update

/**
 * Returns the last release version of this plugin for given system version, regardless of release date
 * @param systemVersion version of host system where plugin will be installed
 * @return PluginRelease which has the highest version number
 */
public PluginRelease getLastRelease(Version systemVersion) {
  if (!lastRelease.containsKey(systemVersion)) {
    for (PluginRelease release : releases) {
      Expression requires = release.getRequiresExpression();
      if (systemVersion.equals(Version.forIntegers(0, 0, 0)) || systemVersion.satisfies(requires)) {
        if (lastRelease.get(systemVersion) == null) {
          lastRelease.put(systemVersion, release);
        } else if (release.compareTo(lastRelease.get(systemVersion)) > 0) {
          lastRelease.put(systemVersion, release);
        }
      }
    }
  }
  return lastRelease.get(systemVersion);
}

代码示例来源:origin: infiniteautomation/ma-core-public

public static final Version normalizeVersion(Version version) {
  return Version.forIntegers(version.getMajorVersion(), version.getMinorVersion(), version.getPatchVersion());
}

代码示例来源:origin: org.ajoberstar.reckon/reckon-core

private Version(com.github.zafarkhaja.semver.Version version) {
 this.version = version;
 // need this if logic to avoid stack overflow
 if (version.getPreReleaseVersion().isEmpty()) {
  this.normal = this;
 } else {
  this.normal = new Version(com.github.zafarkhaja.semver.Version.forIntegers(version.getMajorVersion(), version.getMinorVersion(), version.getPatchVersion()));
 }
 this.stage = Stage.valueOf(version);
}

代码示例来源:origin: org.graylog2/graylog2-server

@Nullable
private Version getMongoVersion(DB adminDb) {
  final CommandResult buildInfoResult = adminDb.command("buildInfo");
  if (buildInfoResult.ok()) {
    final BasicDBList versionArray = (BasicDBList) buildInfoResult.get("versionArray");
    if (versionArray == null || versionArray.size() < 3) {
      LOG.debug("Couldn't retrieve MongoDB version");
      return null;
    }
    final int majorVersion = (int) versionArray.get(0);
    final int minorVersion = (int) versionArray.get(1);
    final int patchVersion = (int) versionArray.get(2);
    return Version.forIntegers(majorVersion, minorVersion, patchVersion);
  } else {
    LOG.debug("Couldn't retrieve MongoDB buildInfo: {}", buildInfoResult.getErrorMessage());
    return null;
  }
}

代码示例来源:origin: ro.fortsoft.pf4j/pf4j

/**
 * Check if this plugin is valid (satisfies "requires" param) for a given system version
 * @param pluginWrapper the plugin to check
 * @return true if plugin satisfies the "requires" or if requires was left blank
 */
protected boolean isPluginValid(PluginWrapper pluginWrapper) {
  String requires = pluginWrapper.getDescriptor().getRequires().trim();
  if (!isExactVersionAllowed() && requires.matches("^\\d+\\.\\d+\\.\\d+$")) {
    // If exact versions are not allowed in requires, rewrite to >= expression
    requires = ">=" + requires;
  }
  if (systemVersion.equals(Version.forIntegers(0,0,0)) || systemVersion.satisfies(requires)) {
    return true;
  }
  log.warn("Plugin '{}:{}' requires a minimum system version of {}, and you have {}",
    pluginWrapper.getPluginId(),
    pluginWrapper.getDescriptor().getVersion(),
    pluginWrapper.getDescriptor().getRequires(),
    getSystemVersion());
  return false;
}

代码示例来源:origin: infiniteautomation/ma-core-public

/**
 * 
 */
public MangoTestModule(String name) {
  super(name, Version.forIntegers(1, 0, 0), 
      new TranslatableMessage("common.default", name), 
      "IAS", "https://www.infiniteautomation.com", null, 1, false);
  this.addDefinition(new MockEventTypeDefinition());
}

代码示例来源:origin: palantir/docker-compose-rule

public void dockerComposeRuleWaitsUntilHealthcheckPasses()
    throws ExecutionException, IOException, InterruptedException, TimeoutException {
  assumeThat("docker version", Docker.version(), new GreaterOrEqual<>(Version.forIntegers(1, 12, 0)));
  assumeThat("docker-compose version", DockerCompose.version(), new GreaterOrEqual<>(Version.forIntegers(1, 10, 0)));

代码示例来源:origin: palantir/docker-compose-rule

/**
   * This test is not currently enabled in Circle as it does not provide a sufficiently recent version of docker-compose.
   *
   * @see <a href="https://github.com/palantir/docker-compose-rule/issues/156">Issue #156</a>
   */
  @Test
  public void testStateChanges_withHealthCheck() throws IOException, InterruptedException {
    assumeThat("docker version", Docker.version(), new GreaterOrEqual<>(Version.forIntegers(1, 12, 0)));
    assumeThat("docker-compose version", DockerCompose.version(), new GreaterOrEqual<>(Version.forIntegers(1, 10, 0)));

    DockerCompose dockerCompose = new DefaultDockerCompose(
        DockerComposeFiles.from("src/test/resources/native-healthcheck.yaml"),
        dockerMachine,
        ProjectName.random());

    // The withHealthcheck service's healthcheck checks every 100ms whether the file "healthy" exists
    Container container = new Container("withHealthcheck", docker, dockerCompose);
    assertEquals(State.DOWN, container.state());
    container.up();
    assertEquals(State.UNHEALTHY, container.state());
    dockerCompose.exec(noOptions(), "withHealthcheck", arguments("touch", "healthy"));
    wait.until(container::state, equalTo(State.HEALTHY));
    dockerCompose.exec(noOptions(), "withHealthcheck", arguments("rm", "healthy"));
    wait.until(container::state, equalTo(State.UNHEALTHY));
    container.kill();
    assertEquals(State.DOWN, container.state());
  }
}

相关文章