@Test public void testIsInRange() throws Exception { Version reference0 = new Version(1, 1, 0, 0); Version reference1 = new Version(1, 1, 0, 1); Version reference2 = new Version(1, 1, 0, 2); Version reference3 = new Version(1, 1, 0, 3); Version reference4 = new Version(1, 1, 0, 4); VersionRange range = VersionRange.parse("[1.1.0.1,1.1.0.3)"); assertFalse(range.isInRange(reference0)); assertTrue(range.isInRange(reference1)); assertTrue(range.isInRange(reference2)); assertFalse(range.isInRange(reference3)); assertFalse(range.isInRange(reference4)); }
public boolean isInRange(Version version) { if (empty) { return false; } if (floorVersion.compareTo(version) >= (isFloorInclusive ? 1 : 0)) { return false; } if (ceilingVersion == null) { return true; } return ceilingVersion.compareTo(version) >= (isCeilingInclusive ? 0 : 1); }
VersionRange { public boolean isInRange(Version version) { if (empty) { return false; } if (floorVersion.compareTo(version) >= (isFloorInclusive ? 1 : 0)) { return false; } if (ceilingVersion == null) { return true; } return ceilingVersion.compareTo(version) >= (isCeilingInclusive ? 0 : 1); } }
VersionRange { public boolean isInRange(Version version) { if (empty) { return false; } if (floorVersion.compareTo(version) >= (isFloorInclusive ? 1 : 0)) { return false; } if (ceilingVersion == null) { return true; } return ceilingVersion.compareTo(version) >= (isCeilingInclusive ? 0 : 1); } VersionRange(Version low, boolean isLowInclusive, Version high, boolean isHighInclusive); }
VersionRange { public boolean isInRange(Version version) { if (empty) { return false; } if (floorVersion.compareTo(version) >= (isFloorInclusive ? 1 : 0)) { return false; } if (ceilingVersion == null) { return true; } return ceilingVersion.compareTo(version) >= (isCeilingInclusive ? 0 : 1); } VersionRange(Version low, boolean isLowInclusive, Version high, boolean isHighInclusive); static VersionRange parse(String range); Version getFloor(); boolean isFloorInclusive(); Version getCeiling(); boolean isCeilingInclusive(); boolean isInRange(Version version); boolean isExact(); boolean isEmpty(); boolean equals(Object obj); @Override int hashCode(); String toString(); }
VersionRange { public boolean isInRange(Version version) { if (empty) { return false; } if (floorVersion.compareTo(version) >= (isFloorInclusive ? 1 : 0)) { return false; } if (ceilingVersion == null) { return true; } return ceilingVersion.compareTo(version) >= (isCeilingInclusive ? 0 : 1); } VersionRange(Version low, boolean isLowInclusive, Version high, boolean isHighInclusive); static VersionRange parse(String range); Version getFloor(); boolean isFloorInclusive(); Version getCeiling(); boolean isCeilingInclusive(); boolean isInRange(Version version); boolean isExact(); boolean isEmpty(); boolean equals(Object obj); @Override int hashCode(); String toString(); static final char LEFT_OPEN; static final char LEFT_CLOSED; static final char RIGHT_OPEN; static final char RIGHT_CLOSED; }