@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override ContiguousSet<C> subSetImpl( C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) { if (fromElement.compareTo(toElement) == 0 && !fromInclusive && !toInclusive) { // Range would reject our attempt to create (x, x). return new EmptyContiguousSet<C>(domain); } return intersectionInCurrentDomain( Range.range( fromElement, BoundType.forBoolean(fromInclusive), toElement, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override ContiguousSet<C> subSetImpl( C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) { if (fromElement.compareTo(toElement) == 0 && !fromInclusive && !toInclusive) { // Range would reject our attempt to create (x, x). return new EmptyContiguousSet<C>(domain); } return intersectionInCurrentDomain( Range.range( fromElement, BoundType.forBoolean(fromInclusive), toElement, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override ContiguousSet<C> subSetImpl( C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) { if (fromElement.compareTo(toElement) == 0 && !fromInclusive && !toInclusive) { // Range would reject our attempt to create (x, x). return new EmptyContiguousSet<C>(domain); } return intersectionInCurrentDomain( Range.range( fromElement, BoundType.forBoolean(fromInclusive), toElement, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
@Override public NavigableMap<Cut<C>, Range<C>> subMap( Cut<C> fromKey, boolean fromInclusive, Cut<C> toKey, boolean toInclusive) { return subMap( Range.range( fromKey, BoundType.forBoolean(fromInclusive), toKey, BoundType.forBoolean(toInclusive))); }
public void testFromRangeTwoEnds() { for (BoundType lowerType : BoundType.values()) { for (BoundType upperType : BoundType.values()) { assertEquals( GeneralRange.range(Ordering.natural(), 3, lowerType, 4, upperType), GeneralRange.from(Range.range(3, lowerType, 4, upperType))); } } }
public void testDoublyBoundedAgainstRange() { for (BoundType lboundType : BoundType.values()) { for (BoundType uboundType : BoundType.values()) { Range<Integer> range = Range.range(2, lboundType, 4, uboundType); GeneralRange<Integer> gRange = GeneralRange.range(ORDERING, 2, lboundType, 4, uboundType); for (Integer i : IN_ORDER_VALUES) { assertEquals(i != null && range.contains(i), gRange.contains(i)); } } } }
public void testAddManyPairs() { for (int aLow = 0; aLow < 6; aLow++) { for (int aHigh = 0; aHigh < 6; aHigh++) { for (BoundType aLowType : BoundType.values()) { for (BoundType aHighType : BoundType.values()) { if ((aLow == aHigh && aLowType == OPEN && aHighType == OPEN) || aLow > aHigh) { continue; } for (int bLow = 0; bLow < 6; bLow++) { for (int bHigh = 0; bHigh < 6; bHigh++) { for (BoundType bLowType : BoundType.values()) { for (BoundType bHighType : BoundType.values()) { if ((bLow == bHigh && bLowType == OPEN && bHighType == OPEN) || bLow > bHigh) { continue; } doPairTest( range(aLow, aLowType, aHigh, aHighType), range(bLow, bLowType, bHigh, bHighType)); } } } } } } } } }
private static Range<Long> toLongRange(final Range<BoundValue> range) { if (!range.hasUpperBound() && !range.hasLowerBound()) { return Range.all(); } else if (range.hasUpperBound() && !range.hasLowerBound()) { return Range.upTo(Long.parseLong(range.upperEndpoint().getValue()), range.upperBoundType()); } else if (!range.hasUpperBound() && range.hasLowerBound()) { return Range.downTo(Long.parseLong(range.lowerEndpoint().getValue()), range.lowerBoundType()); } else { return Range.range( Long.parseLong(range.lowerEndpoint().getValue()), range.lowerBoundType(), Long.parseLong(range.upperEndpoint().getValue()), range.upperBoundType() ); } } }
public void testEquivalentFactories() { new EqualsTester() .addEqualityGroup(Range.all()) .addEqualityGroup(Range.atLeast(1), Range.downTo(1, CLOSED)) .addEqualityGroup(Range.greaterThan(1), Range.downTo(1, OPEN)) .addEqualityGroup(Range.atMost(7), Range.upTo(7, CLOSED)) .addEqualityGroup(Range.lessThan(7), Range.upTo(7, OPEN)) .addEqualityGroup(Range.open(1, 7), Range.range(1, OPEN, 7, OPEN)) .addEqualityGroup(Range.openClosed(1, 7), Range.range(1, OPEN, 7, CLOSED)) .addEqualityGroup(Range.closed(1, 7), Range.range(1, CLOSED, 7, CLOSED)) .addEqualityGroup(Range.closedOpen(1, 7), Range.range(1, CLOSED, 7, OPEN)) .testEquals(); } }
public void testEquals() { new EqualsTester() .addEqualityGroup(Range.open(1, 5), Range.range(1, OPEN, 5, OPEN)) .addEqualityGroup(Range.greaterThan(2), Range.greaterThan(2)) .addEqualityGroup(Range.all(), Range.all()) .addEqualityGroup("Phil") .testEquals(); }
public static Range<BoundValue> toRange(final BoundDimFilter bound) { final BoundValue upper = bound.getUpper() != null ? new BoundValue(bound.getUpper(), bound.getOrdering()) : null; final BoundValue lower = bound.getLower() != null ? new BoundValue(bound.getLower(), bound.getOrdering()) : null; if (lower == null) { return bound.isUpperStrict() ? Range.lessThan(upper) : Range.atMost(upper); } else if (upper == null) { return bound.isLowerStrict() ? Range.greaterThan(lower) : Range.atLeast(lower); } else { BoundType lowerBoundType = bound.isLowerStrict() ? BoundType.OPEN : BoundType.CLOSED; BoundType upperBoundType = bound.isUpperStrict() ? BoundType.OPEN : BoundType.CLOSED; return Range.range(lower, lowerBoundType, upper, upperBoundType); } }
for (BoundType lbType : BoundType.values()) { for (BoundType ubType : BoundType.values()) { rangesBuilder.add(Range.range(i, lbType, j, ubType));