diff --git a/hutool-core/src/test/java/cn/hutool/core/stream/AbstractEnhancedWrappedStreamTest.java b/hutool-core/src/test/java/cn/hutool/core/stream/AbstractEnhancedWrappedStreamTest.java index a509d872b..700b3779f 100644 --- a/hutool-core/src/test/java/cn/hutool/core/stream/AbstractEnhancedWrappedStreamTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/stream/AbstractEnhancedWrappedStreamTest.java @@ -25,43 +25,43 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testToList() { - List list = asList(1, 2, 3); - List toList = wrap(list).toList(); + final List list = asList(1, 2, 3); + final List toList = wrap(list).toList(); Assert.assertEquals(list, toList); } @Test public void testToUnmodifiableList() { - List list = wrap(1, 2, 3) + final List list = wrap(1, 2, 3) .toUnmodifiableList(); Assert.assertThrows(UnsupportedOperationException.class, () -> list.remove(0)); } @Test public void testToSet() { - List list = asList(1, 2, 3); + final List list = asList(1, 2, 3); Set toSet = wrap(list).map(String::valueOf).toSet(); Assert.assertEquals(new HashSet<>(asList("1", "2", "3")), toSet); } @Test public void testToUnmodifiableSet() { - Set set = wrap(1, 2, 3) + final Set set = wrap(1, 2, 3) .toUnmodifiableSet(); Assert.assertThrows(UnsupportedOperationException.class, () -> set.remove(0)); } @Test public void testToCollection() { - List list = asList(1, 2, 3); - List toCollection = wrap(list).map(String::valueOf).toColl(LinkedList::new); + final List list = asList(1, 2, 3); + final List toCollection = wrap(list).map(String::valueOf).toColl(LinkedList::new); Assert.assertEquals(asList("1", "2", "3"), toCollection); } @Test public void testToMap() { - List list = asList(1, 2, 3); - Map identityMap = wrap(list).toMap(String::valueOf); + final List list = asList(1, 2, 3); + final Map identityMap = wrap(list).toMap(String::valueOf); Assert.assertEquals(new HashMap() {{ put("1", 1); put("2", 2); @@ -71,17 +71,17 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testToUnmodifiableMap() { - Map map1 = wrap(1, 2, 3).toUnmodifiableMap(Function.identity(), Function.identity()); + final Map map1 = wrap(1, 2, 3).toUnmodifiableMap(Function.identity(), Function.identity()); Assert.assertThrows(UnsupportedOperationException.class, () -> map1.remove(1)); - Map map2 = wrap(1, 2, 3).toUnmodifiableMap(Function.identity(), Function.identity(), (t1, t2) -> t1); + final Map map2 = wrap(1, 2, 3).toUnmodifiableMap(Function.identity(), Function.identity(), (t1, t2) -> t1); Assert.assertThrows(UnsupportedOperationException.class, () -> map2.remove(1)); } @Test public void testToZip() { - List orders = asList(1, 2, 3); - List list = asList("dromara", "hutool", "sweet"); - Map toZip = wrap(orders).toZip(list); + final List orders = asList(1, 2, 3); + final List list = asList("dromara", "hutool", "sweet"); + final Map toZip = wrap(orders).toZip(list); Assert.assertEquals(new HashMap() {{ put(1, "dromara"); put(2, "hutool"); @@ -91,38 +91,38 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testTransform() { - List list = wrap(1, 2, 3).transform(Wrapper::toList).orElse(null); + final List list = wrap(1, 2, 3).transform(Wrapper::toList).orElse(null); Assert.assertEquals(asList(1, 2, 3), list); } @Test public void testFindFirst() { - List list = asList(1, 2, 3); + final List list = asList(1, 2, 3); Assert.assertEquals((Integer)1, wrap(list).findFirst(t -> (t & 1) == 1).orElse(null)); Assert.assertEquals((Integer)1, wrap(list).filter(t -> (t & 1) == 1).findFirst().orElse(null)); } @Test public void testFindFirstIdx() { - List list = asList(1, 2, 3); + final List list = asList(1, 2, 3); Assert.assertEquals(1, wrap(list).findFirstIdx(t -> (t & 1) == 0)); } @Test public void testFindLast() { - List list = asList(1, 2, 3); + final List list = asList(1, 2, 3); Assert.assertEquals((Integer)3, wrap(list).findLast(t -> (t & 1) == 1).orElse(null)); } @Test public void testFindLastIdx() { - List list = asList(1, 2, 3); + final List list = asList(1, 2, 3); Assert.assertEquals(1, wrap(list).findLastIdx(t -> (t & 1) == 0)); } @Test public void testAt() { - List list = asList(1, 2, 3); + final List list = asList(1, 2, 3); Assert.assertEquals((Integer)3, wrap(list).at(2).orElse(null)); } @@ -140,8 +140,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testJoining() { - List list = asList(1, 2, 3); - String joining = wrap(list).join(); + final List list = asList(1, 2, 3); + final String joining = wrap(list).join(); Assert.assertEquals("123", joining); Assert.assertEquals("1,2,3", wrap(list).join(",")); Assert.assertEquals("(1,2,3)", wrap(list).join(",", "(", ")")); @@ -149,8 +149,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testGrouping() { - List list = asList(1, 2, 3); - Map> map = new HashMap>() {{ + final List list = asList(1, 2, 3); + final Map> map = new HashMap>() {{ put("1", singletonList(1)); put("2", singletonList(2)); put("3", singletonList(3)); @@ -166,8 +166,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testPartitioning() { - List list = asList(1, 2, 3); - Map> map = new HashMap>() {{ + final List list = asList(1, 2, 3); + final Map> map = new HashMap>() {{ put(Boolean.TRUE, singletonList(2)); put(Boolean.FALSE, asList(1, 3)); }}; @@ -180,8 +180,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testForEachIdx() { - List elements = new ArrayList<>(); - List indexes = new ArrayList<>(); + final List elements = new ArrayList<>(); + final List indexes = new ArrayList<>(); wrap(1, 2, 3).forEachIdx((t, i) -> { elements.add(t); indexes.add(i); @@ -192,8 +192,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testForEachOrderedIdx() { - List elements = new ArrayList<>(); - List indexes = new ArrayList<>(); + final List elements = new ArrayList<>(); + final List indexes = new ArrayList<>(); wrap(1, 2, 3).forEachOrderedIdx((t, i) -> { elements.add(t); indexes.add(i); @@ -204,33 +204,33 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testForEachOrdered() { - List elements = new ArrayList<>(); + final List elements = new ArrayList<>(); wrap(1, 2, 3).forEachOrdered(elements::add); Assert.assertEquals(asList(1, 2, 3), elements); } @Test public void testForEach() { - List elements = new ArrayList<>(); + final List elements = new ArrayList<>(); wrap(1, 2, 3).forEach(elements::add); Assert.assertEquals(asList(1, 2, 3), elements); } @Test public void testMapToInt() { - int[] array = wrap(1, 2, 3).mapToInt(Integer::intValue).toArray(); + final int[] array = wrap(1, 2, 3).mapToInt(Integer::intValue).toArray(); Assert.assertArrayEquals(new int[] {1, 2, 3}, array); } @Test public void testMapToLong() { - long[] array = wrap(1L, 2L, 3L).mapToLong(Long::intValue).toArray(); + final long[] array = wrap(1L, 2L, 3L).mapToLong(Long::intValue).toArray(); Assert.assertArrayEquals(new long[] {1L, 2L, 3L}, array); } @Test public void testMapToDouble() { - double[] array = wrap(1d, 2d, 3d).mapToDouble(Double::intValue).toArray(); + final double[] array = wrap(1d, 2d, 3d).mapToDouble(Double::intValue).toArray(); Assert.assertEquals(1d, array[0], 0.01); Assert.assertEquals(2d, array[1], 0.01); Assert.assertEquals(3d, array[2], 0.01); @@ -238,19 +238,19 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testFlatMapToInt() { - int[] array = wrap(1, 2, 3).flatMapToInt(IntStream::of).toArray(); + final int[] array = wrap(1, 2, 3).flatMapToInt(IntStream::of).toArray(); Assert.assertArrayEquals(new int[] {1, 2, 3}, array); } @Test public void testFlatMapToLong() { - long[] array = wrap(1L, 2L, 3L).flatMapToLong(LongStream::of).toArray(); + final long[] array = wrap(1L, 2L, 3L).flatMapToLong(LongStream::of).toArray(); Assert.assertArrayEquals(new long[] {1L, 2L, 3L}, array); } @Test public void testFlatMapToDouble() { - double[] array = wrap(1d, 2d, 3d).flatMapToDouble(DoubleStream::of).toArray(); + final double[] array = wrap(1d, 2d, 3d).flatMapToDouble(DoubleStream::of).toArray(); Assert.assertEquals(1d, array[0], 0.01); Assert.assertEquals(2d, array[1], 0.01); Assert.assertEquals(3d, array[2], 0.01); @@ -258,21 +258,21 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testSorted() { - List list = wrap(3, 1, 2).sorted().toList(); + final List list = wrap(3, 1, 2).sorted().toList(); Assert.assertEquals(asList(1, 2, 3), list); } @Test public void testPeek() { - List elements = new ArrayList<>(); + final List elements = new ArrayList<>(); wrap(1, 2, 3).peek(elements::add).exec(); Assert.assertEquals(asList(1, 2, 3), elements); } @Test public void testPeekIdx() { - List elements = new ArrayList<>(); - List indexes = new ArrayList<>(); + final List elements = new ArrayList<>(); + final List indexes = new ArrayList<>(); wrap(1, 2, 3).peekIdx((t, i) -> { elements.add(t); indexes.add(i); @@ -280,8 +280,8 @@ public class AbstractEnhancedWrappedStreamTest { Assert.assertEquals(asList(1, 2, 3), elements); Assert.assertEquals(asList(0, 1, 2), indexes); - Set elements2 = new HashSet<>(); - Set indexes2 = new HashSet<>(); + final Set elements2 = new HashSet<>(); + final Set indexes2 = new HashSet<>(); wrap(1, 2, null).parallel().peekIdx((t, i) -> { elements2.add(t); indexes2.add(i); @@ -292,13 +292,13 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testLimit() { - List list = wrap(1, 2, 3).limit(2L).toList(); + final List list = wrap(1, 2, 3).limit(2L).toList(); Assert.assertEquals(asList(1, 2), list); } @Test public void testSkip() { - List list = wrap(1, 2, 3).skip(1L).toList(); + final List list = wrap(1, 2, 3).skip(1L).toList(); Assert.assertEquals(asList(2, 3), list); } @@ -366,8 +366,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testIterator() { - Iterator iter1 = Stream.of(1, 2, 3).iterator(); - Iterator iter2 = wrap(1, 2, 3).iterator(); + final Iterator iter1 = Stream.of(1, 2, 3).iterator(); + final Iterator iter2 = wrap(1, 2, 3).iterator(); while (iter1.hasNext() && iter2.hasNext()) { Assert.assertEquals(iter1.next(), iter2.next()); } @@ -375,8 +375,8 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testSpliterator() { - Spliterator iter1 = Stream.of(1, 2, 3).spliterator(); - Spliterator iter2 = wrap(1, 2, 3).spliterator(); + final Spliterator iter1 = Stream.of(1, 2, 3).spliterator(); + final Spliterator iter2 = wrap(1, 2, 3).spliterator(); Assert.assertEquals(iter1.trySplit().estimateSize(), iter2.trySplit().estimateSize()); } @@ -397,14 +397,14 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testOnClose() { - AtomicBoolean atomicBoolean = new AtomicBoolean(false); + final AtomicBoolean atomicBoolean = new AtomicBoolean(false); wrap(Stream.of(1, 2, 3).onClose(() -> atomicBoolean.set(true))).close(); Assert.assertTrue(atomicBoolean.get()); } @Test public void testClose() { - Wrapper stream = wrap(Stream.of(1, 2, 3)); + final Wrapper stream = wrap(Stream.of(1, 2, 3)); stream.close(); Assert.assertThrows(IllegalStateException.class, stream::exec); } @@ -500,7 +500,7 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testFilterIdx() { - List indexes = new ArrayList<>(); + final List indexes = new ArrayList<>(); Assert.assertEquals( asList(1, 3), wrap(1, 2, 3).filterIdx((t, i) -> { @@ -527,7 +527,7 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testFlatMapIdx() { - List indexes = new ArrayList<>(); + final List indexes = new ArrayList<>(); Assert.assertEquals( asList(1, 2, 3), wrap(1, 2, 3).flatMapIdx((t, i) -> { indexes.add(i); @@ -553,7 +553,7 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testFlatTree() { - Tree root = new Tree(1, asList(new Tree(2, asList(new Tree(3, Collections.emptyList()))))); + final Tree root = new Tree(1, asList(new Tree(2, asList(new Tree(3, Collections.emptyList()))))); Assert.assertEquals(3L, wrap(root).flatTree(Tree::getChildren, Tree::setChildren).count()); } @@ -573,7 +573,7 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testMapIdx() { - List indexes = new ArrayList<>(); + final List indexes = new ArrayList<>(); Assert.assertEquals( asList("1", "2", "3"), wrap(1, 2, 3).mapIdx((t, i) -> { indexes.add(i); @@ -595,25 +595,25 @@ public class AbstractEnhancedWrappedStreamTest { @Test public void testHashCode() { - Stream stream = Stream.of(1, 2, 3); + final Stream stream = Stream.of(1, 2, 3); Assert.assertEquals(stream.hashCode(), wrap(stream).hashCode()); } @Test public void testEquals() { - Stream stream = Stream.of(1, 2, 3); + final Stream stream = Stream.of(1, 2, 3); Assert.assertEquals(wrap(stream), stream); } @Test public void testToString() { - Stream stream = Stream.of(1, 2, 3); + final Stream stream = Stream.of(1, 2, 3); Assert.assertEquals(stream.toString(), wrap(stream).toString()); } @Test public void testToEntries() { - Map expect = new HashMap(){{ + final Map expect = new HashMap(){{ put(1, 1); put(2, 2); put(3, 3); diff --git a/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java b/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java index dfe056b1f..26fa81ef8 100644 --- a/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/stream/EasyStreamTest.java @@ -22,8 +22,8 @@ public class EasyStreamTest { @Test public void testConcat() { - Stream stream1 = Stream.of(1, 2); - Stream stream2 = Stream.of(3, 4); + final Stream stream1 = Stream.of(1, 2); + final Stream stream2 = Stream.of(3, 4); Assert.assertEquals(4, EasyStream.concat(stream1, stream2).count()); } diff --git a/hutool-core/src/test/java/cn/hutool/core/stream/EntryStreamTest.java b/hutool-core/src/test/java/cn/hutool/core/stream/EntryStreamTest.java index 532460166..7d23e00d1 100644 --- a/hutool-core/src/test/java/cn/hutool/core/stream/EntryStreamTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/stream/EntryStreamTest.java @@ -46,12 +46,12 @@ public class EntryStreamTest { @Test public void testOf() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put("1", "1"); Assert.assertEquals(1, EntryStream.of(map).count()); Assert.assertEquals(0, EntryStream.of((Map)null).count()); - Set> entries = new HashSet<>(); + final Set> entries = new HashSet<>(); entries.add(new Entry<>(1, 1)); entries.add(null); Assert.assertEquals(2, EntryStream.of(entries).count()); @@ -61,7 +61,7 @@ public class EntryStreamTest { Assert.assertEquals(2, new EntryStream<>(entries.stream()).count()); Assert.assertThrows(NullPointerException.class, () -> new EntryStream<>(null)); - Iterable iterable = Arrays.asList(1, 2, null); + final Iterable iterable = Arrays.asList(1, 2, null); Assert.assertEquals(3, EntryStream.of(iterable, Function.identity(), Function.identity()).count()); Assert.assertEquals(0, EntryStream.of(null, Function.identity(), Function.identity()).count()); } @@ -73,7 +73,7 @@ public class EntryStreamTest { @Test public void testDistinctByKey() { - long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) + final long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .distinctByKey() .count(); Assert.assertEquals(2, count); @@ -81,7 +81,7 @@ public class EntryStreamTest { @Test public void testDistinctByValue() { - long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) + final long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .distinctByValue() .count(); Assert.assertEquals(2, count); @@ -89,7 +89,7 @@ public class EntryStreamTest { @Test public void testFilter() { - long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) + final long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .filter((k, v) -> k == 1 && v == 1) .count(); Assert.assertEquals(1, count); @@ -97,7 +97,7 @@ public class EntryStreamTest { @Test public void testFilterByKey() { - long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) + final long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .filterByKey(k -> k == 1) .count(); Assert.assertEquals(2, count); @@ -105,7 +105,7 @@ public class EntryStreamTest { @Test public void testFilterByValue() { - long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) + final long count = EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .filterByValue(v -> v == 1) .count(); Assert.assertEquals(2, count); @@ -113,7 +113,7 @@ public class EntryStreamTest { @Test public void testPeekKey() { - List keys = new ArrayList<>(); + final List keys = new ArrayList<>(); EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .peekKey(keys::add) .count(); @@ -122,7 +122,7 @@ public class EntryStreamTest { @Test public void testPeekValue() { - List values = new ArrayList<>(); + final List values = new ArrayList<>(); EntryStream.of(Arrays.asList(new Entry<>(1, 1), new Entry<>(1, 2), new Entry<>(2, 1), new Entry<>(2, 2))) .peekValue(values::add) .count(); @@ -153,11 +153,11 @@ public class EntryStreamTest { @Test public void testAppend() { - Map map1 = new HashMap(){{ + final Map map1 = new HashMap(){{ put(1, 1); put(2, 2); }}; - Map map2 = new HashMap(){{ + final Map map2 = new HashMap(){{ put(3, 3); put(4, 4); }}; @@ -175,11 +175,11 @@ public class EntryStreamTest { @Test public void testPrepend() { - Map map1 = new HashMap(){{ + final Map map1 = new HashMap(){{ put(1, 1); put(2, 2); }}; - Map map2 = new HashMap(){{ + final Map map2 = new HashMap(){{ put(3, 3); put(4, 4); }}; @@ -197,7 +197,7 @@ public class EntryStreamTest { @Test public void testSortByKey() { - List> entries = EntryStream.of(Arrays.asList(new Entry<>(3, 1), new Entry<>(2, 1), new Entry<>(4, 1), new Entry<>(1, 1))) + final List> entries = EntryStream.of(Arrays.asList(new Entry<>(3, 1), new Entry<>(2, 1), new Entry<>(4, 1), new Entry<>(1, 1))) .sortByKey(Comparator.comparingInt(Integer::intValue)) .collect(Collectors.toList()); Assert.assertEquals( @@ -208,7 +208,7 @@ public class EntryStreamTest { @Test public void testSortByValue() { - List> entries = EntryStream.of(Arrays.asList(new Entry<>(4, 4), new Entry<>(2, 2), new Entry<>(1, 1), new Entry<>(3, 3))) + final List> entries = EntryStream.of(Arrays.asList(new Entry<>(4, 4), new Entry<>(2, 2), new Entry<>(1, 1), new Entry<>(3, 3))) .sortByValue(Comparator.comparingInt(Integer::intValue)) .collect(Collectors.toList()); Assert.assertEquals( @@ -219,7 +219,7 @@ public class EntryStreamTest { @Test public void testToValueStream() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -230,7 +230,7 @@ public class EntryStreamTest { @Test public void testToKeyStream() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -241,7 +241,7 @@ public class EntryStreamTest { @Test public void testCollectKey() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -251,7 +251,7 @@ public class EntryStreamTest { @Test public void testCollectValue() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -261,7 +261,7 @@ public class EntryStreamTest { @Test public void testMapKeys() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -276,7 +276,7 @@ public class EntryStreamTest { @Test public void testMapValues() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -291,7 +291,7 @@ public class EntryStreamTest { @Test public void testMap() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -311,7 +311,7 @@ public class EntryStreamTest { @Test public void testFlatMap() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -323,11 +323,11 @@ public class EntryStreamTest { @Test public void testFlatMapValue() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put("class1", 1); map.put("class2", 2); map.put("class3", 3); - List values = EntryStream.of(map) + final List values = EntryStream.of(map) .flatMapKey(k -> Stream.of(k + "'s student1", k + "'s student2")) .map((k, v) -> v + "=" + k) .sorted() @@ -344,11 +344,11 @@ public class EntryStreamTest { @Test public void testInverse() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); - List results = EntryStream.of(map) + final List results = EntryStream.of(map) .inverse() .map((k, v) -> k + "=" + v) .collect(Collectors.toList()); @@ -360,11 +360,11 @@ public class EntryStreamTest { @Test public void testFlatMapKey() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, "class1"); map.put(2, "class2"); map.put(3, "class3"); - List values = EntryStream.of(map) + final List values = EntryStream.of(map) .flatMapValue(v -> Stream.of(v + "'s student1", v + "'s student2")) .map((k, v) -> k + "=" + v) .collect(Collectors.toList()); @@ -380,13 +380,13 @@ public class EntryStreamTest { @Test public void testForEach() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); - List keys = new ArrayList<>(); - List values = new ArrayList<>(); + final List keys = new ArrayList<>(); + final List values = new ArrayList<>(); EntryStream.of(map).forEach((k ,v) -> { keys.add(k); values.add(v); @@ -397,7 +397,7 @@ public class EntryStreamTest { @Test public void testToMap() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -414,7 +414,7 @@ public class EntryStreamTest { @Test public void testToTable() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -438,7 +438,7 @@ public class EntryStreamTest { @Test public void testToTableByKey() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -462,7 +462,7 @@ public class EntryStreamTest { @Test public void testToTableByValue() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); @@ -486,19 +486,19 @@ public class EntryStreamTest { @Test public void testGroupByKey() { - Map> map1 = EntryStream.of(Arrays.asList(1, 1, 2, 2), Function.identity(), Function.identity()) + final Map> map1 = EntryStream.of(Arrays.asList(1, 1, 2, 2), Function.identity(), Function.identity()) .groupByKey(); Assert.assertEquals(2, map1.size()); Assert.assertEquals(Arrays.asList(1, 1), map1.get(1)); Assert.assertEquals(Arrays.asList(2, 2), map1.get(2)); - Map> map2 = EntryStream.of(Arrays.asList(1, 1, 2, 2), Function.identity(), Function.identity()) + final Map> map2 = EntryStream.of(Arrays.asList(1, 1, 2, 2), Function.identity(), Function.identity()) .groupByKey(Collectors.toSet()); Assert.assertEquals(2, map2.size()); Assert.assertEquals(Collections.singleton(1), map2.get(1)); Assert.assertEquals(Collections.singleton(2), map2.get(2)); - Map> map3 = EntryStream.of(Arrays.asList(1, 1, 2, 2), Function.identity(), Function.identity()) + final Map> map3 = EntryStream.of(Arrays.asList(1, 1, 2, 2), Function.identity(), Function.identity()) .groupByKey(LinkedHashMap::new, Collectors.toSet()); Assert.assertEquals(2, map3.size()); Assert.assertEquals(Collections.singleton(1), map3.get(1)); @@ -531,7 +531,7 @@ public class EntryStreamTest { @Test public void testNonNull() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, null); map.put(null, 1); Assert.assertEquals(0, EntryStream.of(map).nonNullKeyValue().count()); @@ -539,7 +539,7 @@ public class EntryStreamTest { @Test public void testKeyNonNull() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, null); map.put(null, 1); Assert.assertEquals(1, EntryStream.of(map).nonNullKey().count()); @@ -547,7 +547,7 @@ public class EntryStreamTest { @Test public void testValueNonNull() { - Map map = new HashMap<>(); + final Map map = new HashMap<>(); map.put(1, null); map.put(null, 1); Assert.assertEquals(1, EntryStream.of(map).nonNullValue().count());