upperBound = range.getMax();
if (res1.getMin() == null || res2.getMax() == null || res1.getMin().compareTo(res2.getMax()) <= 0) if (res1.getMax() == null || res2.getMin() == null || res1.getMax().compareTo(res2.getMin()) >= 0) if (res1.getMax() == null) max = res2.getMax(); maxInclusive = res2.isMaxInclusive(); else if (res2.getMax() == null) max = res1.getMax(); maxInclusive = res1.isMaxInclusive(); int comparison = res1.getMax().compareTo(res2.getMax()); if (comparison < 0) max = res1.getMax(); maxInclusive = res1.isMaxInclusive(); max = res1.getMax(); maxInclusive = res1.isMaxInclusive() && res2.isMaxInclusive(); max = res2.getMax(); maxInclusive = res2.isMaxInclusive(); if (max == res2.getMax())
/** * Calculate the intersection of one or more {@link VersionRange} instances, returning a single {@link VersionRange} * as the result. */ public static VersionRange intersection(Collection<VersionRange> ranges) { Assert.notNull(ranges, "Version ranges must not be null."); Assert.isTrue(ranges.size() >= 1, "Version ranges must not be empty."); Version min = null; Version max = null; boolean minInclusive = false; boolean maxInclusive = false; for (VersionRange range : ranges) { if (min == null || range.getMin().compareTo(min) > 0) { min = range.getMin(); minInclusive = range.isMinInclusive(); } if (max == null || range.getMax().compareTo(max) < 0) { max = range.getMax(); maxInclusive = range.isMaxInclusive(); } } return new DefaultVersionRange(min, minInclusive, max, maxInclusive); }