org.identityconnectors.common.Version类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(216)

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

Version介绍

[英]Encapsulates a version number. A version number is composed of up to four components: major, minor, micro and specification number.
[中]封装一个版本号。版本号最多由四个部分组成:主版本号、次版本号、微版本号和规格号。

代码示例

代码示例来源:origin: net.tirasa.connid/connector-framework

if (isCeilingInclusive) {
  return floorVersion.equals(ceilingVersion);
} else {
      new Version(floorVersion.getMajor(), floorVersion.getMinor(), floorVersion
          .getMicro(), floorVersion.getRevision() + 1);
  return adjacent1.compareTo(ceilingVersion) >= 0;
      new Version(floorVersion.getMajor(), floorVersion.getMinor(), floorVersion
          .getMicro(), floorVersion.getRevision() + 1);
  return adjacent1.equals(ceilingVersion);
} else {
      new Version(floorVersion.getMajor(), floorVersion.getMinor(), floorVersion
          .getMicro(), floorVersion.getRevision() + 2);
  return adjacent2.compareTo(ceilingVersion) >= 0;

代码示例来源:origin: net.tirasa.connid/connector-framework

public String toString() {
    if (ceilingVersion != null) {
      StringBuilder sb = new StringBuilder();
      sb.append(isFloorInclusive ? LEFT_CLOSED : LEFT_OPEN);
      sb.append(floorVersion.getVersion()).append(ENDPOINT_DELIMITER).append(
          ceilingVersion.getVersion());
      sb.append(isCeilingInclusive ? RIGHT_CLOSED : RIGHT_OPEN);
      return sb.toString();
    } else {
      return floorVersion.getVersion();
    }
  }
}

代码示例来源:origin: net.tirasa.connid/connector-framework

/**
 * Returns this version as a string.
 *
 * @return this version as a string.
 */
public String getVersion() {
  StringBuilder builder = new StringBuilder();
  appendTo(builder);
  return builder.toString();
}

代码示例来源:origin: org.connid/framework

/**
 * Parses the passed version string. The string can contain up to
 * four numeric component separated by a dot, followed by an alphanumberic
 * qualifier prepended by a dash. For example, the following are valid
 * versions:
 * <ul>
 *   <li>1</li>
 *   <li>1.1</li>
 *   <li>1.1.0</li>
 *   <li>1.2.3-alpha</li>
 *   <li>1.2.3.4-SNAPSHOT</li>
 * </ul>
 *
 * @param version the version string.
 */
public static Version parse(String version) {
  return new Version(parseInternal(version));
}

代码示例来源:origin: org.connid/connid-framework-internal

/**
 * Parses the manifest.
 * @return The manifest. Note that the classes/classloaders will
 * not be populated yet. That is to be done at a higher-level.
 * @throws ConfigurationException If there were any structural problems.
 */
public ConnectorBundleManifest parse() throws ConfigurationException {
  String frameworkVersion = getRequiredAttribute(ATT_FRAMEWORK_VERSION);
  String bundleName = getRequiredAttribute(ATT_BUNDLE_NAME);
  String bundleVersion =getRequiredAttribute(ATT_BUNDLE_VERSION);
  if (FrameworkUtil.getFrameworkVersion().compareTo(Version.parse(frameworkVersion)) < 0) {
    String message = "Bundle " + _fileName + " requests an unrecognized " +
        "framework version " + frameworkVersion + " but available is " +
        FrameworkUtil.getFrameworkVersion().getVersion();
    throw new ConfigurationException(message);
  }
  ConnectorBundleManifest rv = new ConnectorBundleManifest();
  rv.setFrameworkVersion(frameworkVersion);
  rv.setBundleName(bundleName);
  rv.setBundleVersion(bundleVersion);
  return rv;
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void testComponents() {
  Version v = Version.parse("1.2.3.4");
  assertEquals(v.getMajor(), Integer.valueOf(1));
  assertEquals(v.getMinor(), Integer.valueOf(2));
  assertEquals(v.getMicro(), Integer.valueOf(3));
  assertEquals(v.getRevision(), Integer.valueOf(4));
}

代码示例来源:origin: org.connid/framework

@Override
public boolean equals(Object o) {
  if (o instanceof Version) {
    return compareTo((Version) o) == 0;
  }
  return false;
}

代码示例来源:origin: Tirasa/ConnId

if (ATT_FRAMEWORK_VERSION.equals(key)) {
  frameworkVersion = (String) bundleHeaders.get(key);
  if (version.compareTo(Version.parse(frameworkVersion)) < 0) {

代码示例来源:origin: Tirasa/ConnId

/**
 * Parse version component into a Version.
 *
 * @param version
 *            version component string
 * @param range
 *            Complete range string for exception message, if any
 * @return Version
 */
private static Version parseVersion(String version, String range) {
  try {
    return Version.parse(version);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(
        "invalid range \"" + range + "\": " + e.getMessage(), e);
  }
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void testParse() {
  assertEquals(new Version(1), Version.parse("1"));
  assertEquals(new Version(1), Version.parse("1-alpha"));
  assertEquals(new Version(1, 2), Version.parse("1.2"));
  assertEquals(new Version(1, 2), Version.parse("1.2-alpha"));
  assertEquals(new Version(1, 2, 3), Version.parse("1.2.3"));
  assertEquals(new Version(1, 2, 3), Version.parse("1.2.3-alpha"));
  assertEquals(new Version(1, 2, 3, 4), Version.parse("1.2.3.4"));
  assertEquals(new Version(1, 2, 3, 4), Version.parse("1.2.3.4-alpha"));
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void testEqualsHashCode() {
  Version v1 = Version.parse("1.0");
  Version v2 = Version.parse("1.0.0.0");
  assertEquals(v1, v2);
  assertEquals(v1.hashCode(), v2.hashCode());
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void testToString() {
  assertEquals(Version.parse("1.2.3").toString(), "Version[1.2.3]");
}

代码示例来源:origin: org.connid/framework

/**
 * Returns this version number's minor component.
 *
 * @return the minor component or <code>null</code> if this version
 *         number doesn't have a minor component.
 */
public Integer getMicro() {
  return getComponent(MICRO);
}

代码示例来源:origin: org.connid/framework

/**
 * Creates a new version from components.
 *
 * @param components the components
 */
public static Version create(Integer... components) {
  return new Version(components);
}

代码示例来源:origin: net.tirasa.connid/connector-framework-internal

/**
 * Parses the manifest.
 *
 * @return The manifest. Note that the classes/classloaders will not be populated yet. That is to be done at a
 * higher-level.
 * @throws ConfigurationException if there were any structural problems.
 */
public ConnectorBundleManifest parse() throws ConfigurationException {
  String frameworkVersion = getRequiredAttribute(ATT_FRAMEWORK_VERSION);
  String bundleName = getRequiredAttribute(ATT_BUNDLE_NAME);
  String bundleVersion = getRequiredAttribute(ATT_BUNDLE_VERSION);
  if (FrameworkUtil.getFrameworkVersion().compareTo(Version.parse(frameworkVersion)) < 0) {
    String message =
        "Bundle " + fileName + " requests an unrecognized " + "framework version "
        + frameworkVersion + " but available is "
        + FrameworkUtil.getFrameworkVersion().getVersion();
    throw new ConfigurationException(message);
  }
  ConnectorBundleManifest rv = new ConnectorBundleManifest();
  rv.setFrameworkVersion(frameworkVersion);
  rv.setBundleName(bundleName);
  rv.setBundleVersion(bundleVersion);
  return rv;
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void testCornerCases() {
  Version v = Version.parse("1.0");
  assertEquals(v.getMajor(), Integer.valueOf(1));
  assertEquals(v.getMinor(), Integer.valueOf(0));
  assertNull(v.getMicro());
  assertNull(v.getRevision());
  try {
    new Version();
    fail();
  } catch (IllegalArgumentException e) {
    // OK.
  }
  try {
    Version.parse(" ");
    fail();
  } catch (IllegalArgumentException e) {
    // OK.
  }
  try {
    Version.parse("foo");
    fail();
  } catch (IllegalArgumentException e) {
    // OK.
  }
}

代码示例来源:origin: net.tirasa.connid/connector-framework

@Override
public boolean equals(Object o) {
  if (o instanceof Version) {
    return compareTo((Version) o) == 0;
  }
  return false;
}

代码示例来源:origin: net.tirasa.connid/connector-framework

/**
 * Parse version component into a Version.
 *
 * @param version
 *            version component string
 * @param range
 *            Complete range string for exception message, if any
 * @return Version
 */
private static Version parseVersion(String version, String range) {
  try {
    return Version.parse(version);
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(
        "invalid range \"" + range + "\": " + e.getMessage(), e);
  }
}

代码示例来源:origin: Tirasa/ConnId

@Test
public void testCompare() {
  assertCompEq(new Version(1), Version.parse("1"));
  assertCompEq(new Version(1, 2), Version.parse("1.2"));
  assertCompEq(new Version(1, 2, 3), Version.parse("1.2.3"));
  assertCompEq(new Version(1, 2, 3, 4), Version.parse("1.2.3.4"));
  assertCompEq(new Version(1), Version.parse("1.0"));
  assertCompEq(new Version(1), Version.parse("1.0.0"));
  assertCompEq(new Version(1), Version.parse("1.0.0.0"));
  assertCompEq(new Version(1, 2), Version.parse("1.2.0"));
  assertCompEq(new Version(1, 2), Version.parse("1.2.0.0"));
  assertCompEq(new Version(1, 2, 3), Version.parse("1.2.3.0"));
  assertCompLt(new Version(1, 2), Version.parse("1.3"));
  assertCompLt(new Version(1, 2, 3), Version.parse("1.2.4"));
  assertCompLt(new Version(1, 2, 3, 4), Version.parse("1.2.3.5"));
  assertCompLt(new Version(2), Version.parse("3"));
  assertCompLt(new Version(2), Version.parse("2.1"));
  assertCompLt(new Version(2, 3), Version.parse("2.3.4"));
  assertCompLt(new Version(2, 3, 4), Version.parse("2.3.4.5"));
  assertCompGt(new Version(1, 2), Version.parse("1.1"));
  assertCompGt(new Version(1, 2, 3), Version.parse("1.2.2"));
  assertCompGt(new Version(1, 2, 3, 4), Version.parse("1.2.3.3"));
  assertCompGt(new Version(2), Version.parse("1"));
  assertCompGt(new Version(2), Version.parse("1.0"));
  assertCompGt(new Version(2, 3), Version.parse("2.2.0"));
  assertCompGt(new Version(2, 3, 4), Version.parse("2.3.3.0"));
}

代码示例来源:origin: net.tirasa.connid/connector-framework

/**
 * Parses the passed version string. The string can contain up to four
 * numeric component separated by a dot, followed by an alphanumberic
 * qualifier prepended by a dash. For example, the following are valid
 * versions:
 * <ul>
 * <li>1</li>
 * <li>1.1</li>
 * <li>1.1.0</li>
 * <li>1.2.3-alpha</li>
 * <li>1.2.3.4-SNAPSHOT</li>
 * </ul>
 *
 * @param version
 *            the version string.
 */
public static Version parse(String version) {
  return new Version(parseInternal(version));
}

相关文章