info.magnolia.module.model.Version.isEquivalent()方法的使用及代码示例

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

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

Version.isEquivalent介绍

[英]Compares major, minor and patch revisions of this Version against the given Version. Classifier is ignored.
[中]将此版本的主要版本、次要版本和修补程序版本与给定版本进行比较。分类器被忽略。

代码示例

代码示例来源:origin: info.magnolia/magnolia-core

public boolean contains(Version other) {
  if (other.isEquivalent(from) && leftBoundary.include) {
    return true;
  }
  if (other.isEquivalent(to) && rightBoundary.include) {
    return true;
  }
  return other.isStrictlyAfter(from) && to.isStrictlyAfter(other);
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
  public int compare(Version v1, Version v2) {
    if (v1.isStrictlyAfter(v2)) {
      return 1;
    } else if (v1.isEquivalent(v2)) {
      return 0;
    } else {
      return -1;
    }
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

protected List<Delta> getUpdateDeltas(InstallContext installContext, Version from) {
  final Version toVersion = installContext.getCurrentModuleDefinition().getVersion();
  final List<Delta> deltas = new LinkedList<>();
  for (Version v : allDeltas.keySet()) {
    if (v.isStrictlyAfter(toVersion)) {
      throw new IllegalArgumentException("Cannot handle delta for version '" + v.toString() + "' while only installing version '" + toVersion.toString() + "' of module '" + installContext.getCurrentModuleDefinition().getName() + "'.");
    }
    if (v.isStrictlyAfter(from)) {
      final Delta delta = allDeltas.get(v);
      if (v.isEquivalent(toVersion) && !StringUtils.equals(v.getClassifier(), toVersion.getClassifier())) {
        delta.getTasks().add(new ModuleVersionUpdateTask(toVersion));
      }
      deltas.add(delta);
    }
  }
  // if there was no delta for the version being installed, we still need to add the default update tasks
  if (toVersion.isStrictlyAfter(from) && !allDeltas.containsKey(toVersion)) {
    deltas.add(getDefaultUpdate(installContext));
  }
  return deltas;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void test3and300shouldBeEquivalent() {
  assertTrue(Version.parseVersion("3").isEquivalent(Version.parseVersion("3.0.0")));
  assertFalse(Version.parseVersion("3.0.1").isEquivalent(Version.parseVersion("3.0.0")));
  assertFalse(Version.parseVersion("3.1.1").isEquivalent(Version.parseVersion("3.0.0")));
  assertFalse(Version.parseVersion("4.1.1").isEquivalent(Version.parseVersion("3.0.0")));
  assertFalse(Version.parseVersion("3.0.1").isEquivalent(Version.parseVersion("3.0.2")));
  assertFalse(Version.parseVersion("3.0.1").isEquivalent(Version.parseVersion("3.2.2")));
  assertFalse(Version.parseVersion("3.0.1").isEquivalent(Version.parseVersion("2.2.2")));
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void testClassifiersShouldBeIgnoredInEquivalenceComparison() {
  assertTrue(Version.parseVersion("3-foo").isEquivalent(Version.parseVersion("3.0.0")));
  assertTrue(Version.parseVersion("3.0.0").isEquivalent(Version.parseVersion("3.0.0-bar")));
  assertTrue(Version.parseVersion("3.0.0-baz").isEquivalent(Version.parseVersion("3.0.0-bar")));
}

代码示例来源:origin: net.sourceforge.openutils/openutils-mgnlutils

if (!to.isEquivalent(from)
  || "${project.version}".equals(ObjectUtils.toString(from))
  || "SNAPSHOT".equals(from.getClassifier()))

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void testUndefinedDeveloperVersion() {
  Version realVersion = new Version(3, 1, 1);
  assertTrue(Version.parseVersion(Version.UndefinedDevelopmentVersion.KEY) instanceof UndefinedDevelopmentVersion);
  assertTrue(Version.UNDEFINED_DEVELOPMENT_VERSION.isEquivalent(realVersion));
  assertTrue(Version.UNDEFINED_DEVELOPMENT_VERSION.isBeforeOrEquivalent(realVersion));
  assertFalse(Version.UNDEFINED_DEVELOPMENT_VERSION.isStrictlyAfter(realVersion));
  assertTrue(realVersion.isEquivalent(Version.UNDEFINED_DEVELOPMENT_VERSION));
  assertTrue(realVersion.isBeforeOrEquivalent(Version.UNDEFINED_DEVELOPMENT_VERSION));
  assertFalse(realVersion.isStrictlyAfter(Version.UNDEFINED_DEVELOPMENT_VERSION));
  assertTrue(Version.UNDEFINED_DEVELOPMENT_VERSION.isEquivalent(Version.UNDEFINED_DEVELOPMENT_VERSION));
  assertTrue(Version.UNDEFINED_DEVELOPMENT_VERSION.isBeforeOrEquivalent(Version.UNDEFINED_DEVELOPMENT_VERSION));
  assertFalse(Version.UNDEFINED_DEVELOPMENT_VERSION.isStrictlyAfter(Version.UNDEFINED_DEVELOPMENT_VERSION));
}

代码示例来源:origin: info.magnolia/magnolia-core

public boolean isStrictlyAfter(final Version other) {
  if (isEquivalent(other)) {
    return false;
  }
  if (this.getMajor() != other.getMajor()) {
    return this.getMajor() > other.getMajor();
  }
  if (this.getMinor() != other.getMinor()) {
    return this.getMinor() > other.getMinor();
  }
  if (this.getPatch() != other.getPatch()) {
    return this.getPatch() > other.getPatch();
  }
  return false;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void testSingleVersionCanBeSpecified() {
  final VersionRange range = VersionRange.parse("1.2.3");
  VersionTest.assertVersion(1, 2, 3, null, range.getFrom());
  VersionTest.assertVersion(1, 2, 3, null, range.getTo());
  assertTrue(range.getFrom().isEquivalent(range.getTo()));
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void testFromAndToCanBeSame() {
  final VersionRange range = VersionRange.parse("3.0.0/3.0.0");
  VersionTest.assertVersion(3, 0, 0, null, range.getFrom());
  VersionTest.assertVersion(3, 0, 0, null, range.getTo());
  assertTrue(range.getFrom().isEquivalent(range.getTo()));
}

代码示例来源:origin: info.magnolia/magnolia-core

@Test
public void testClassifiersAreAcceptedEvenIfFromAndToAreSame() {
  final VersionRange range = VersionRange.parse("3.0.0-pouet/3.0.0-tralala");
  VersionTest.assertVersion(3, 0, 0, "pouet", range.getFrom());
  VersionTest.assertVersion(3, 0, 0, "tralala", range.getTo());
  assertTrue(range.getFrom().isEquivalent(range.getTo()));
}

相关文章