in vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/VersionRange.java [72:119]
public VersionRange(Version low, boolean lowIncl, Version high, boolean highIncl) {
if (low == Version.EMPTY) {
low = null;
}
if (high == Version.EMPTY) {
high = null;
}
// check if range is valid
if (low != null && high != null) {
int comp = low.compareTo(high);
if (comp > 0) {
throw new IllegalArgumentException("lower bound must be less or equal to upper bound.");
} else if (comp == 0) {
if (!lowIncl || !highIncl) {
throw new IllegalArgumentException("invalid empty range. upper and lower bound must be inclusive.");
}
}
}
this.low = low;
this.lowIncl = lowIncl;
this.high = high;
this.highIncl = highIncl;
StringBuilder b = new StringBuilder();
if (low == null && high == null) {
// infinite range, empty string
} else if (high == null) {
// no high bound,
if (lowIncl) {
// special case, just use version
b.append(low);
} else {
b.append('(');
b.append(low);
b.append(",)");
}
} else if (low == null) {
b.append("[,");
b.append(high);
b.append(highIncl ? ']' : ')');
} else {
b.append(lowIncl ? '[' : '(');
b.append(low);
b.append(',');
b.append(high);
b.append(highIncl ? ']' : ')');
}
this.str = b.toString();
}