Codota Logo
Version
Code IndexAdd Codota to your IDE (free)

How to use
Version
in
com.wlqq.mavenversion

Best Java code snippets using com.wlqq.mavenversion.Version (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: ManbangGroup/Phantom

@Test
public void testCreateVersion() throws Exception {
  // org.infinispan:infinispan-directory-provider:9.2.0.Alpha2
  Version version = new Version("9.2.0.Alpha2");
  // junit:junit:4.12
  version = new Version("4.12");
  // org.json:json:20171018
  version = new Version("20171018");
  // io.reactivex.rxjava2:rxjava:2.1.6
  version = new Version("2.1.6");
  // io.reactivex.rxjava2:rxjava:2.1.6-SNAPSHOT
  version = new Version("2.1.6-SNAPSHOT");
}
origin: ManbangGroup/Phantom

/**
 * Checks if this version is greater than or equal to the other version.
 *
 * @param other the other version to compare to
 * @return {@code true} if this version is greater than or equal
 * to the other version or {@code false} otherwise
 * @see #compareTo(Version other)
 */
public boolean greaterThanOrEqualTo(Version other) {
  return compareTo(other) >= 0;
}
origin: ManbangGroup/Phantom

  /**
   * Checks if the current version equals the parsed version.
   *
   * @param version the version to compare to, the left-hand
   *                operand of the "equal" operator
   * @return {@code true} if the version equals the
   *         parsed version or {@code false} otherwise
   */
  @Override
  public boolean interpret(Version version) {
    return version.equals(mParsedVersion);
  }
}
origin: ManbangGroup/Phantom

/**
 * Check lib version satisfies lib version requirements
 *
 * @param versions     e.g. <code>{"junit:junit": "4.12", "com.android.support:support-v4": "25.3.1"}</code>
 * @param requirements e.g. <code>{"junit:junit": "4.12", "com.android.support:support-v4": ">=25"}</code>
 * @return verify result
 * @see Result
 */
public static Result satisfies(Map<String, String> versions, Map<String, String> requirements) {
  for (Map.Entry<String, String> entry : requirements.entrySet()) {
    final String lib = entry.getKey();
    final String requirement = entry.getValue();
    final String version = versions.get(lib);
    if (version == null) {
      // lib not exist
      return Result.createFailResult(lib, String.format(Locale.ENGLISH, "required lib [%s] not exist", lib));
    }
    if (!new Version(version).satisfies(requirement)) {
      // lib version requirement not satisfied
      return Result.createFailResult(lib, String.format(Locale.ENGLISH,
              "required lib [%s:%s] not satisfies [%s:%s]", lib, version, lib, requirement));
    }
  }
  return Result.createSuccessResult();
}
origin: ManbangGroup/Phantom

@Test
public void testCompareVersionEquals() throws Exception {
  {
    Version version1 = new Version("27.0.0");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.compareTo(version2) == 0);
  }
  {
    Version version1 = new Version("27.0");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.compareTo(version2) == 0);
  }
  {
    Version version1 = new Version("27");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.compareTo(version2) == 0);
  }
  {
    Version version1 = new Version("27");
    Version version2 = new Version("27.0");
    Assert.assertTrue(version1.compareTo(version2) == 0);
  }
  {
    Version version1 = new Version("27.0");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.compareTo(version2) == 0);
  }
}
origin: ManbangGroup/Phantom

@Test
public void testCompareVersionEquals2() throws Exception {
  {
    Version version1 = new Version("27.0.0");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.equals(version2));
  }
  {
    Version version1 = new Version("27.0");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.equals(version2));
  }
  {
    Version version1 = new Version("27");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.equals(version2));
  }
  {
    Version version1 = new Version("27");
    Version version2 = new Version("27.0");
    Assert.assertTrue(version1.equals(version2));
  }
  {
    Version version1 = new Version("27.0");
    Version version2 = new Version("27.0.0");
    Assert.assertTrue(version1.equals(version2));
  }
}
origin: ManbangGroup/Phantom

final String newVersion = parts[2];
final String oldVersion = librariesMap.get(lib);
if (oldVersion != null && new Version(newVersion).lessThan(new Version(oldVersion))) {
origin: ManbangGroup/Phantom

/**
 * Creates a new instance of {@code Version} as a
 * result of parsing the specified version string.
 *
 * @param version the version string to parse
 * @return a new instance of the {@code Version} class
 */
public Version(String version) {
  parseVersion(version);
}
origin: ManbangGroup/Phantom

    list.add(IntegerItem.ZERO);
  } else {
    list.add(parseItem(isDigit, version.substring(startIndex, i)));
    list.add(IntegerItem.ZERO);
  } else {
    list.add(parseItem(isDigit, version.substring(startIndex, i)));
} else {
  if (isDigit && i > startIndex) {
    list.add(parseItem(true, version.substring(startIndex, i)));
    startIndex = i;
list.add(parseItem(isDigit, version.substring(startIndex)));
origin: ManbangGroup/Phantom

@Test
public void testInvalidExpressionSatisfiesShouldReturnFalse() throws Exception {
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("=27.0.0"));
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("==27.0.0"));
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies(">27.0.0"));
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("<27.0.0"));
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("<=27.0.0"));
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("!=27.0.0"));
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("27.0.0-prerelease"));
origin: ManbangGroup/Phantom

Version version1 = new Version("27.0.0");
Version version2 = new Version("26.0.0");
Assert.assertTrue(version1.compareTo(version2) > 0);
Version version1 = new Version("26.0.1");
Version version2 = new Version("26.0.0");
Assert.assertTrue(version1.compareTo(version2) > 0);
Version version1 = new Version("26.0.1");
Version version2 = new Version("26.0");
Assert.assertTrue(version1.compareTo(version2) > 0);
Version version1 = new Version("26.0.1");
Version version2 = new Version("26");
Assert.assertTrue(version1.compareTo(version2) > 0);
Version version1 = new Version("26.1");
Version version2 = new Version("26");
Assert.assertTrue(version1.compareTo(version2) > 0);
Version version1 = new Version("20171218");
Version version2 = new Version("20171018");
Assert.assertTrue(version1.compareTo(version2) > 0);
origin: com.wlqq.phantom/maven-version

/**
 * Creates a new instance of {@code Version} as a
 * result of parsing the specified version string.
 *
 * @param version the version string to parse
 * @return a new instance of the {@code Version} class
 */
public Version(String version) {
  parseVersion(version);
}
origin: com.wlqq.phantom/maven-version

    list.add(IntegerItem.ZERO);
  } else {
    list.add(parseItem(isDigit, version.substring(startIndex, i)));
    list.add(IntegerItem.ZERO);
  } else {
    list.add(parseItem(isDigit, version.substring(startIndex, i)));
} else {
  if (isDigit && i > startIndex) {
    list.add(parseItem(true, version.substring(startIndex, i)));
    startIndex = i;
list.add(parseItem(isDigit, version.substring(startIndex)));
origin: ManbangGroup/Phantom

@Test
public void testSatisfiesEqual() throws Exception {
  {
    Version version = new Version("27.0.0");
    Assert.assertTrue(version.satisfies("27.0.0"));
  }
  {
    Version version = new Version("27.0.0");
    Assert.assertTrue(version.satisfies("27.0"));
  }
  {
    Version version = new Version("27.0.0");
    Assert.assertTrue(version.satisfies("27"));
  }
  {
    Version version = new Version("27.0.0");
    Assert.assertFalse(version.satisfies("27.0.1"));
  }
  {
    Version version = new Version("27.0.0-SNAPSHOT");
    Assert.assertTrue(version.satisfies("27.0.0-SNAPSHOT"));
    Assert.assertFalse(version.satisfies("27.0.1-SNAPSHOT"));
    Assert.assertFalse(version.satisfies("27.0.0"));
  }
}
origin: ManbangGroup/Phantom

/**
 * Checks if this version is greater than the other version.
 *
 * @param other the other version to compare to
 * @return {@code true} if this version is greater than the other version
 * or {@code false} otherwise
 * @see #compareTo(Version other)
 */
public boolean greaterThan(Version other) {
  return compareTo(other) > 0;
}
origin: ManbangGroup/Phantom

  @Override
  public Expression parse(String input) throws ParseException {
    boolean isGte = false;
    String versionText;
    if (input.startsWith(">=")) {
      isGte = true;
      // strip operator
      versionText = input.substring(2);
    } else {
      versionText = input;
    }

    final Version parsedVersion = new Version(versionText);
    if (isGte) {
      return new GreaterOrEqual(parsedVersion);
    } else {
      return new Equal(parsedVersion);
    }
  }
}
origin: com.wlqq.phantom/maven-version

  /**
   * Checks if the current version equals the parsed version.
   *
   * @param version the version to compare to, the left-hand
   *                operand of the "equal" operator
   * @return {@code true} if the version equals the
   *         parsed version or {@code false} otherwise
   */
  @Override
  public boolean interpret(Version version) {
    return version.equals(mParsedVersion);
  }
}
origin: ManbangGroup/Phantom

Version version = new Version("27.0.0");
Assert.assertTrue(version.satisfies(">=27.0.0"));
Version version = new Version("27.0.1");
Assert.assertTrue(version.satisfies(">=27.0"));
Version version = new Version("27.1.0");
Assert.assertTrue(version.satisfies(">=27"));
Version version = new Version("27.0.0");
Assert.assertFalse(version.satisfies(">=27.1.0"));
Version version = new Version("27");
Assert.assertTrue(version.satisfies(">=26.9999999.9999999.99999999.99999999999"));
Version version = new Version("20171018");
Assert.assertTrue(version.satisfies(">=20161018"));
Assert.assertFalse(version.satisfies("20161018"));
Version version = new Version("27.0.0");
Assert.assertFalse(version.satisfies("27.0.0-SNAPSHOT"));
Assert.assertTrue(version.satisfies(">=27.0.0-SNAPSHOT"));
Version version = new Version("28.0.0");
Assert.assertFalse(version.satisfies("27.0.0-SNAPSHOT"));
Assert.assertTrue(version.satisfies(">=27.0.0-SNAPSHOT"));
Version version = new Version("28.0.0");
Assert.assertTrue(version.satisfies(">=28.0.0-beta.2"));
origin: ManbangGroup/Phantom

/**
 * Checks if this version is less than or equal to the other version.
 *
 * @param other the other version to compare to
 * @return {@code true} if this version is less than or equal
 * to the other version or {@code false} otherwise
 * @see #compareTo(Version other)
 */
public boolean lessThanOrEqualTo(Version other) {
  return compareTo(other) <= 0;
}
origin: com.wlqq.phantom/maven-version

  @Override
  public Expression parse(String input) throws ParseException {
    boolean isGte = false;
    String versionText;
    if (input.startsWith(">=")) {
      isGte = true;
      // strip operator
      versionText = input.substring(2);
    } else {
      versionText = input;
    }

    final Version parsedVersion = new Version(versionText);
    if (isGte) {
      return new GreaterOrEqual(parsedVersion);
    } else {
      return new Equal(parsedVersion);
    }
  }
}
com.wlqq.mavenversionVersion

Javadoc

Generic implementation of version comparison.

Features:
  • mixing of '-' (hyphen) and '.' (dot) separators,
  • transition between characters and digits also constitutes a separator: 1.0alpha1 => [1, 0, alpha, 1]
  • unlimited number of version components,
  • version components in the text can be digits or strings,
  • strings are checked for well-known qualifiers and the qualifier ordering is used for version ordering. Well-known qualifiers (case insensitive) are:
    • alpha or a
    • beta or b
    • milestone or m
    • rc or cr
    • snapshot
    • (the empty string) or ga or final
    • sp
    Unknown qualifiers are considered after known qualifiers, with lexical order (always case insensitive),
  • a hyphen usually precedes a qualifier, and is always less important than something preceded with a dot.

Most used methods

  • <init>
    Creates a new instance of Version as a result of parsing the specified version string.
  • compareTo
  • equals
  • satisfies
    Checks if this version satisfies the specified SemVer Expression string. Supported expression: * e
  • parseItem
  • parseVersion
  • lessThan
    Checks if this version is less than the other version.

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • setContentView (Activity)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • ArrayList (java.util)
    Resizable-array implementation of the List interface. Implements all optional list operations, and p
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now