info.magnolia.module.model.Version类的使用及代码示例

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

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

Version介绍

[英]Represents a module version. Format is x.y.z-classifier. y,z and classifier are optional. The classifier string is ignored in version comparisons.
[中]表示模块版本。格式为x.y.z-classifier。y、 z和分类器是可选的。在版本比较中忽略分类器字符串。

代码示例

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

@Override
  public Object convert(Class type, Object value) {
    return Version.parseVersion((String) value);
  }
}

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

/**
 * Compares major, minor and patch revisions of this Version against the given Version.
 * Classifier is ignored.
 */
public boolean isEquivalent(final Version other) {
  if (other == UNDEFINED_DEVELOPMENT_VERSION) {
    return true;
  }
  return this.getMajor() == other.getMajor() &&
      this.getMinor() == other.getMinor() &&
      this.getPatch() == other.getPatch();
}

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

public static VersionMatcher version(String strVersion) {
  final Version version = Version.parseVersion(strVersion);
  return version().
      withMajor(equalTo(version.getMajor())).
      withMinor(equalTo(version.getMinor())).
      withPatch(equalTo(version.getPatch())).
      withClassifier(equalTo(version.getClassifier()));
}

代码示例来源: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: com.kasisoft.mgnl/ks-mgnl-versionhandler

public KsSetModuleVersionTask( @Nonnull String module, @Nonnull String prop, @Nonnull Version toVersion ) {
 super( String.format( FMT_PROPERTY, module, prop ), toVersion.toString() );
}

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

public static Version parseVersion(int major, int minor, int patch) {
  return new Version(major, minor, patch);
}

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

public static void assertVersion(int expectedMajor, int expectedMinor, int expectedPatch, String expectedClassifier, Version actual) {
  assertEquals("major revision:", expectedMajor, actual.getMajor());
  assertEquals("minor revision:", expectedMinor, actual.getMinor());
  assertEquals("minor revision:", expectedPatch, actual.getPatch());
  assertEquals("classifier:", expectedClassifier, actual.getClassifier());
}

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

/**
 * {@inheritDoc}
 */
public void start(ModuleLifecycleContext ctx)
{
  log.info("Starting module media");
  if (ctx != null)
  {
    ctx.registerModuleObservingComponent("mediatypes", (ObservedManager) mediaConfigurationManager);
    version = ctx.getCurrentModuleDefinition().getVersion().toString();
  }
}

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

@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

/**
 * Factory method that will parse a version string and return the correct Version implementation.
 *
 * @param versionStr version as string, for example <code>1.2.3-test</code>. The String
 * <code>${project.version}</code> is interpreted as an undefined version during development ant it will always
 * match version ranges
 * @return a Version implementation, never null
 */
public static Version parseVersion(String versionStr) {
  versionStr = versionStr.trim();
  log.debug("parsing version [{}]", versionStr);
  if (UndefinedDevelopmentVersion.isDevelopmentVersion(versionStr)) {
    // development mode.
    return UNDEFINED_DEVELOPMENT_VERSION;
  }
  return new Version(versionStr);
}

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

@Override
  public Object convert(Class type, Object value) {
    return Version.parseVersion(String.valueOf(value));
  }
}, Version.class);

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

@Override
protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException {
  // make sure we have the /modules node
  if (!ctx.hasModulesNode()) {
    final Session session = ctx.getConfigJCRSession();
    session.getRootNode().addNode(ModuleManagerImpl.MODULES_NODE, NodeTypes.Content.NAME);
  }
  final Node moduleNode = ctx.getOrCreateCurrentModuleNode();
  PropertyUtil.setProperty(moduleNode, "version", getVersion(ctx).toString());
}

相关文章