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

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

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

Version.getPreReleaseVersion介绍

[英]Returns the string representation of the pre-release version.
[中]返回预发布版本的字符串表示形式。

代码示例

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

final int minor = version.getMinorVersion();
final int patch = version.getPatchVersion();
final String qualifier = version.getPreReleaseVersion();

代码示例来源: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: org.ajoberstar.reckon/reckon-core

/**
 * @return {@code true} if this is a final version (i.e. doesn't have pre-release information),
 *         {@code false} otherwise
 */
public boolean isFinal() {
 return version.getPreReleaseVersion().isEmpty();
}

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

private static Stage valueOf(com.github.zafarkhaja.semver.Version version) {
  Matcher matcher = STAGE_REGEX.matcher(version.getPreReleaseVersion());
  if (matcher.find()) {
   String name = matcher.group("name");
   int num = Optional.ofNullable(matcher.group("num")).map(Integer::parseInt).orElse(0);
   return new Stage(name, num);
  } else {
   return null;
  }
 }
}

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

/**
 * {@inheritDoc}
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(getNormalVersion());
  if (!getPreReleaseVersion().isEmpty()) {
    sb.append(PRE_RELEASE_PREFIX).append(getPreReleaseVersion());
  }
  if (!getBuildMetadata().isEmpty()) {
    sb.append(BUILD_PREFIX).append(getBuildMetadata());
  }
  return sb.toString();
}

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

/**
 * {@inheritDoc}.
 */
@Override
public String toString() {
 StringBuilder sb = new StringBuilder(getNormalVersion());
 if (!getPreReleaseVersion().isEmpty()) {
  sb.append(PRE_RELEASE_PREFIX).append(getPreReleaseVersion());
 }
 if (!getBuildMetadata().isEmpty()) {
  sb.append(BUILD_PREFIX).append(getBuildMetadata());
 }
 return sb.toString();
}

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

/**
 * {@inheritDoc}
 */
@Override
public String toString() {
  StringBuilder sb = new StringBuilder(getNormalVersion());
  if (!getPreReleaseVersion().isEmpty()) {
    sb.append(PRE_RELEASE_PREFIX).append(getPreReleaseVersion());
  }
  if (!getBuildMetadata().isEmpty()) {
    sb.append(BUILD_PREFIX).append(getBuildMetadata());
  }
  return sb.toString();
}

代码示例来源:origin: org.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: org.ajoberstar/semver-vcs-api

private static Version sanitizeStage(Version inferred, String stage, boolean fixed) {
  String[] rawIdents = inferred.getPreReleaseVersion().split("\\.");
  int rawEndIndex = getEndIndex(rawIdents, 0);
  int limit;
  if (stage.equals(rawIdents[0])) {
    limit = 2;
  } else if (!fixed) {
    if (rawIdents.length > 2 && stage.equals(rawIdents[2])) {
      limit = 4;
    } else {
      limit = 2;
    }
  } else {
    return Version.valueOf(inferred.getNormalVersion());
  }
  int endIndex = Math.min(rawEndIndex, limit);
  String[] validIdents = Arrays.copyOfRange(rawIdents, 0, endIndex);
  String preRelease = String.join(".", validIdents);
  if (preRelease == null || preRelease.isEmpty()) {
    return inferred;
  } else {
    return inferred.setPreReleaseVersion(preRelease);
  }
}

代码示例来源:origin: org.ajoberstar/semver-vcs-api

/**
 * Floating stages will behave as a fixed stage if the previous versions stage
 * either doesn't exist or has a lower precedence. If the previous has a higher
 * precedence, the pre-release information will be of the form
 * {@code <previous stage>.<previous count>.<stage name>.<incremented count>}.
 * @param name the name of the stage
 * @return a floating stage
 */
public static Stage floatingStage(String name) {
  return new Stage(name, (base, vcs) -> {
    Version sanitized = sanitizeStage(base, name, false);
    String[] prevStages = sanitized.getPreReleaseVersion().split("\\.");
    if (Arrays.binarySearch(prevStages, name) >= 0) {
      return sanitized.incrementPreReleaseVersion();
    } else if (name.compareTo(prevStages[0]) > 0) {
      return sanitized.setPreReleaseVersion(name).incrementPreReleaseVersion();
    } else {
      return sanitized.setPreReleaseVersion(sanitized.getPreReleaseVersion() + "." + name).incrementPreReleaseVersion();
    }
  });
}

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

final int minor = version.getMinorVersion();
final int patch = version.getPatchVersion();
final String qualifier = version.getPreReleaseVersion();

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

/**
 * Setup the core and modules for request
 * @param coreVersion
 * @param moduleVersionState
 */
protected void setupModules(Version coreVersion, String moduleVersion) {
  switch(coreVersion.getPreReleaseVersion()){
    case "SNAPSHOT":
      json.put("currentVersionState", UpgradeVersionState.DEVELOPMENT);
    break;
    default:
      json.put("currentVersionState", UpgradeVersionState.PRODUCTION);
  }
  jsonModules.put("core", coreVersion.toString());
  for(String module : modules) {
    jsonModules.put(module, moduleVersion);
  }
}

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

/**
 * Setup the core and modules for request
 * @param coreVersion
 * @param moduleVersionState
 */
protected void setupModules(Version coreVersion, String moduleVersion) {
  switch(coreVersion.getPreReleaseVersion()){
    case "SNAPSHOT":
      json.put("currentVersionState", UpgradeVersionState.DEVELOPMENT);
    break;
    default:
      json.put("currentVersionState", UpgradeVersionState.PRODUCTION);
  }
  jsonModules.put("core", coreVersion.toString());
  for(String module : modules) {
    jsonModules.put(module, moduleVersion);
  }
}

代码示例来源: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.ajoberstar/semver-vcs-api

/**
 * Fixed stages will always use pre-release information of the form
 * {@code <stage name>.<incremented count>}, where the count is always 1,
 * unless the previous version used the same stage. In that case the
 * count will be incremented from the previous.
 * @param name the name of the stage
 * @return a fixed stage
 */
public static Stage fixedStage(String name) {
  return new Stage(name, (base, vcs) -> {
    Version sanitized = sanitizeStage(base, name, true);
    String previousStage = sanitized.getPreReleaseVersion().split("\\.")[0];
    if (name.equals(previousStage)) {
      return sanitized.incrementPreReleaseVersion();
    } else {
      return base.setPreReleaseVersion(name).incrementPreReleaseVersion();
    }
  });
}

代码示例来源:origin: org.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());
  }
}

相关文章