use of org.sonatype.aether.version.VersionRange in project sonatype-aether by sonatype.
the class GenericVersionRangeTest method testSingleVersion.
@Test
public void testSingleVersion() {
VersionRange range = parseValid("[1]");
assertContains(range, "1");
assertEquals(range, parseValid(range.toString()));
range = parseValid("[1,1]");
assertContains(range, "1");
assertEquals(range, parseValid(range.toString()));
}
use of org.sonatype.aether.version.VersionRange in project sonatype-aether by sonatype.
the class GenericVersionRangeTest method testLowerBoundInclusiveUpperBoundInclusive.
@Test
public void testLowerBoundInclusiveUpperBoundInclusive() {
VersionRange range = parseValid("[1,2]");
assertContains(range, "1");
assertContains(range, "1.1-SNAPSHOT");
assertContains(range, "2");
assertEquals(range, parseValid(range.toString()));
}
use of org.sonatype.aether.version.VersionRange in project sonatype-aether by sonatype.
the class GenericVersionScheme method parseVersionConstraint.
public VersionConstraint parseVersionConstraint(final String constraint) throws InvalidVersionSpecificationException {
GenericVersionConstraint result = new GenericVersionConstraint();
String process = constraint;
while (process.startsWith("[") || process.startsWith("(")) {
int index1 = process.indexOf(')');
int index2 = process.indexOf(']');
int index = index2;
if (index2 < 0 || (index1 >= 0 && index1 < index2)) {
index = index1;
}
if (index < 0) {
throw new InvalidVersionSpecificationException(constraint, "Unbounded version range " + constraint);
}
VersionRange range = parseVersionRange(process.substring(0, index + 1));
result.addRange(range);
process = process.substring(index + 1).trim();
if (process.length() > 0 && process.startsWith(",")) {
process = process.substring(1).trim();
}
}
if (process.length() > 0 && !result.getRanges().isEmpty()) {
throw new InvalidVersionSpecificationException(constraint, "Invalid version range " + constraint + ", expected [ or ( but got " + process);
}
if (result.getRanges().isEmpty()) {
result.setVersion(parseVersion(constraint));
}
return result;
}
Aggregations