/** * 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; }
/** * 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; }
/** * 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; }
/** * Checks if this version is less than the other version. * * @param other the other version to compare to * @return {@code true} if this version is less than the other version * or {@code false} otherwise * @see #compareTo(Version other) */ public boolean lessThan(Version other) { return compareTo(other) < 0; }
/** * Checks if the current version is greater * than or equal to the parsed version. * * @param version the version to compare to, the left-hand operand * of the "greater than or equal to" operator * @return {@code true} if the version is greater than or equal * to the parsed version or {@code false} otherwise */ @Override public boolean interpret(Version version) { return version.compareTo(mParsedVersion) >= 0; } }
@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); } }
Version version2 = new Version("26.0.0"); Assert.assertTrue(version1.compareTo(version2) > 0); Version version2 = new Version("26.0.0"); Assert.assertTrue(version1.compareTo(version2) > 0); Version version2 = new Version("26.0"); Assert.assertTrue(version1.compareTo(version2) > 0); Version version2 = new Version("26"); Assert.assertTrue(version1.compareTo(version2) > 0); Version version2 = new Version("26"); Assert.assertTrue(version1.compareTo(version2) > 0); Assert.assertTrue(version1.compareTo(version2) > 0);
/** * Checks if this version is less than the other version. * * @param other the other version to compare to * @return {@code true} if this version is less than the other version * or {@code false} otherwise * @see #compareTo(Version other) */ public boolean lessThan(Version other) { return compareTo(other) < 0; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Checks if the current version is greater * than or equal to the parsed version. * * @param version the version to compare to, the left-hand operand * of the "greater than or equal to" operator * @return {@code true} if the version is greater than or equal * to the parsed version or {@code false} otherwise */ @Override public boolean interpret(Version version) { return version.compareTo(mParsedVersion) >= 0; } }