@Test public void reverseForEachOnFromToInterval() { List<Integer> result = new ArrayList<>(); Interval interval = Interval.oneTo(5); interval.reverseForEach(result::add); Verify.assertSize(5, result); Verify.assertContains(1, result); Verify.assertContains(5, result); Assert.assertEquals(Integer.valueOf(5), Iterate.getFirst(result)); Assert.assertEquals(Integer.valueOf(1), Iterate.getLast(result)); result.clear(); interval.reverseThis().reverseForEach(result::add); Verify.assertSize(5, result); Verify.assertContains(1, result); Verify.assertContains(5, result); Assert.assertEquals(Integer.valueOf(1), Iterate.getFirst(result)); Assert.assertEquals(Integer.valueOf(5), Iterate.getLast(result)); }
@Override public I valueOf(T1 object) { for (Function<T1, I> function : this.functions) { I result = function.valueOf(object); if (Iterate.notEmpty(result)) { return result; } } return null; }
@Test public void entrySet() { MutableSortedMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "2").asUnmodifiable(); Verify.assertThrows(UnsupportedOperationException.class, () -> map.entrySet().remove(null)); Verify.assertThrows( UnsupportedOperationException.class, () -> Iterate.getFirst(map.entrySet()).setValue("Three")); Assert.assertEquals(this.newMapWithKeysValues(1, "One", 2, "2"), map); }
@Override public ImmutableSetMultimap<V, K> flip() { return Iterate.flip(this).toImmutable(); }
@Override public int intValueOf(Iterable<?> iterable) { return Iterate.sizeOf(iterable); }