/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys ranges * from {@code fromKey}, inclusive, to {@code toKey}, exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a submap throws an {@link * IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code fromKey}. * However, this method doesn't throw an exception in that situation, but instead keeps the * original {@code fromKey}. Similarly, this method keeps the original {@code toKey}, instead of * throwing an exception, if passed a {@code toKey} greater than an earlier {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys ranges * from {@code fromKey}, inclusive, to {@code toKey}, exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a submap throws an {@link * IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code fromKey}. * However, this method doesn't throw an exception in that situation, but instead keeps the * original {@code fromKey}. Similarly, this method keeps the original {@code toKey}, instead of * throwing an exception, if passed a {@code toKey} greater than an earlier {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
@Override protected SortedMap<String, Integer> makePopulatedMap() { return ImmutableSortedMap.of("a", 1, "b", 2, "c", 3, "d", 4, "e", 5).subMap("b", "d"); }
@SuppressWarnings("unchecked") // varargs public void testSubMapExclusiveExclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", false, "two", false); assertThat(map.entrySet()).containsExactly(Maps.immutableEntry("three", 3)); }
@SuppressWarnings("unchecked") // varargs public void testSubMapExclusiveInclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", false, "two", true); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("three", 3), Maps.immutableEntry("two", 2)) .inOrder(); }
@SuppressWarnings("unchecked") // varargs public void testSubMapInclusiveExclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", true, "two", false); assertThat(map.entrySet()) .containsExactly(Maps.immutableEntry("one", 1), Maps.immutableEntry("three", 3)) .inOrder(); }
@SuppressWarnings("unchecked") // varargs public void testSubMapInclusiveInclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", true, "two", true); assertThat(map.entrySet()) .containsExactly( Maps.immutableEntry("one", 1), Maps.immutableEntry("three", 3), Maps.immutableEntry("two", 2)) .inOrder(); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys ranges * from {@code fromKey}, inclusive, to {@code toKey}, exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a submap throws an {@link * IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code fromKey}. * However, this method doesn't throw an exception in that situation, but instead keeps the * original {@code fromKey}. Similarly, this method keeps the original {@code toKey}, instead of * throwing an exception, if passed a {@code toKey} greater than an earlier {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys ranges * from {@code fromKey}, inclusive, to {@code toKey}, exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a submap throws an {@link * IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code fromKey}. * However, this method doesn't throw an exception in that situation, but instead keeps the * original {@code fromKey}. Similarly, this method keeps the original {@code toKey}, instead of * throwing an exception, if passed a {@code toKey} greater than an earlier {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries * whose keys ranges from {@code fromKey}, inclusive, to {@code toKey}, * exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a * submap throws an {@link IllegalArgumentException} if passed a {@code * fromKey} less than an earlier {@code fromKey}. However, this method doesn't * throw an exception in that situation, but instead keeps the original {@code * fromKey}. Similarly, this method keeps the original {@code toKey}, instead * of throwing an exception, if passed a {@code toKey} greater than an earlier * {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries * whose keys ranges from {@code fromKey}, inclusive, to {@code toKey}, * exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a * submap throws an {@link IllegalArgumentException} if passed a {@code * fromKey} less than an earlier {@code fromKey}. However, this method doesn't * throw an exception in that situation, but instead keeps the original {@code * fromKey}. Similarly, this method keeps the original {@code toKey}, instead * of throwing an exception, if passed a {@code toKey} greater than an earlier * {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries * whose keys ranges from {@code fromKey}, inclusive, to {@code toKey}, * exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a * submap throws an {@link IllegalArgumentException} if passed a {@code * fromKey} less than an earlier {@code fromKey}. However, this method doesn't * throw an exception in that situation, but instead keeps the original {@code * fromKey}. Similarly, this method keeps the original {@code toKey}, instead * of throwing an exception, if passed a {@code toKey} greater than an earlier * {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries * whose keys ranges from {@code fromKey}, inclusive, to {@code toKey}, * exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a * submap throws an {@link IllegalArgumentException} if passed a {@code * fromKey} less than an earlier {@code fromKey}. However, this method doesn't * throw an exception in that situation, but instead keeps the original {@code * fromKey}. Similarly, this method keeps the original {@code toKey}, instead * of throwing an exception, if passed a {@code toKey} greater than an earlier * {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries * whose keys ranges from {@code fromKey}, inclusive, to {@code toKey}, * exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a * submap throws an {@link IllegalArgumentException} if passed a {@code * fromKey} less than an earlier {@code fromKey}. However, this method doesn't * throw an exception in that situation, but instead keeps the original {@code * fromKey}. Similarly, this method keeps the original {@code toKey}, instead * of throwing an exception, if passed a {@code toKey} greater than an earlier * {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries * whose keys ranges from {@code fromKey}, inclusive, to {@code toKey}, * exclusive. * * <p>The {@link SortedMap#subMap} documentation states that a submap of a * submap throws an {@link IllegalArgumentException} if passed a {@code * fromKey} less than an earlier {@code fromKey}. However, this method doesn't * throw an exception in that situation, but instead keeps the original {@code * fromKey}. Similarly, this method keeps the original {@code toKey}, instead * of throwing an exception, if passed a {@code toKey} greater than an earlier * {@code toKey}. */ @Override public ImmutableSortedMap<K, V> subMap(K fromKey, K toKey) { return subMap(fromKey, true, toKey, false); }
@Override protected SortedMap<String, Integer> makePopulatedMap() { return ImmutableSortedMap.of("a", 1, "b", 2, "c", 3, "d", 4, "e", 5) .subMap("b", "d"); }
@SuppressWarnings("unchecked") // varargs public void testSubMapExclusiveExclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", false, "two", false); assertThat(map.entrySet()).containsExactly(Maps.immutableEntry("three", 3)); }
@SuppressWarnings("unchecked") // varargs public void testSubMapInclusiveInclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", true, "two", true); assertThat(map.entrySet()).containsExactly(Maps.immutableEntry("one", 1), Maps.immutableEntry("three", 3), Maps.immutableEntry("two", 2)).inOrder(); }
@SuppressWarnings("unchecked") // varargs public void testSubMapExclusiveInclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", false, "two", true); assertThat(map.entrySet()).containsExactly(Maps.immutableEntry("three", 3), Maps.immutableEntry("two", 2)).inOrder(); }
@SuppressWarnings("unchecked") // varargs public void testSubMapInclusiveExclusive() { Map<String, Integer> map = ImmutableSortedMap.of("one", 1, "two", 2, "three", 3).subMap("one", true, "two", false); assertThat(map.entrySet()).containsExactly(Maps.immutableEntry("one", 1), Maps.immutableEntry("three", 3)).inOrder(); }