From 847f47ee0172ae336176c312eba5ceee0152278b Mon Sep 17 00:00:00 2001 From: Andreas Hufler Date: Tue, 13 Jan 2026 10:30:37 +0100 Subject: [PATCH 1/2] fix nullability issue --- .../springboot/toolbox/util/CollectUtil.java | 7 ++----- .../springboot/toolbox/util/CollectUtilTest.java | 11 +++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/it/aboutbits/springboot/toolbox/util/CollectUtil.java b/src/main/java/it/aboutbits/springboot/toolbox/util/CollectUtil.java index 5631699..0ad559a 100644 --- a/src/main/java/it/aboutbits/springboot/toolbox/util/CollectUtil.java +++ b/src/main/java/it/aboutbits/springboot/toolbox/util/CollectUtil.java @@ -1,7 +1,6 @@ package it.aboutbits.springboot.toolbox.util; import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; import org.springframework.data.util.Streamable; import java.util.Collection; @@ -94,12 +93,11 @@ public static Stream collectToStream(Stream items, NullableFunction } public static Map collectToMap( - Collection<@Nullable T> items, + Collection items, Function keyMapper, Function valueMapper ) { return items.stream() - .filter(Objects::nonNull) .collect(Collectors.toMap(keyMapper, valueMapper)); } @@ -113,12 +111,11 @@ public static Map collectToMap( } public static Map collectToMap( - Stream<@Nullable T> items, + Stream items, Function keyMapper, Function valueMapper ) { return items - .filter(Objects::nonNull) .collect(Collectors.toMap(keyMapper, valueMapper)); } } diff --git a/src/test/java/it/aboutbits/springboot/toolbox/util/CollectUtilTest.java b/src/test/java/it/aboutbits/springboot/toolbox/util/CollectUtilTest.java index 4d605fd..7cf8768 100644 --- a/src/test/java/it/aboutbits/springboot/toolbox/util/CollectUtilTest.java +++ b/src/test/java/it/aboutbits/springboot/toolbox/util/CollectUtilTest.java @@ -1,7 +1,6 @@ package it.aboutbits.springboot.toolbox.util; import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -381,7 +380,7 @@ class CollectToMap { @DisplayName("Should convert Collection to Map using key and value mappers") void shouldConvertCollectionToMapUsingMappers() { // given - var items = (Collection<@Nullable String>) Arrays.asList("a", "bb", "ccc"); + var items = (Collection) Arrays.asList("a", "bb", "ccc"); // when var result = CollectUtil.collectToMap(items, String::length, Function.identity()); @@ -398,7 +397,7 @@ void shouldConvertCollectionToMapUsingMappers() { @DisplayName("Should throw on duplicate keys according to Collectors.toMap default behavior") void shouldThrowOnDuplicateKeys() { // given - var items = (Collection<@Nullable String>) Arrays.asList("a", "b"); // both have length of 1 + var items = (Collection) Arrays.asList("a", "b"); // both have length of 1 // when / then assertThatIllegalStateException().isThrownBy( @@ -431,7 +430,7 @@ void shouldConvertStreamableToMapUsingMappers() { @DisplayName("Should convert Stream to Map using key and value mappers") void shouldConvertStreamToMapUsingMappers() { // given - var items = Stream.<@Nullable String>of("m", "nn"); + var items = Stream.of("m", "nn"); // when var result = CollectUtil.collectToMap(items, String::length, Function.identity()); @@ -447,7 +446,7 @@ void shouldConvertStreamToMapUsingMappers() { @DisplayName("Should return empty map for empty collection") void shouldReturnEmptyMapForEmptyCollection() { // given - var items = Collections.<@Nullable String>emptyList(); + var items = Collections.emptyList(); // when var result = CollectUtil.collectToMap(items, String::length, Function.identity()); @@ -473,7 +472,7 @@ void shouldReturnEmptyMapForEmptyStreamable() { @DisplayName("Should return empty map for empty stream") void shouldReturnEmptyMapForEmptyStream() { // given - var items = Stream.<@Nullable String>empty(); + var items = Stream.empty(); // when var result = CollectUtil.collectToMap(items, String::length, Function.identity()); From cbd42faaf68a46073f6a35f67e91b2e044f6b5a7 Mon Sep 17 00:00:00 2001 From: Andreas Hufler Date: Tue, 13 Jan 2026 10:31:23 +0100 Subject: [PATCH 2/2] update deps --- pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index cdca341..7f67ccb 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -17,8 +18,8 @@ 25 - 2.45.0 - 0.12.14 + 2.46.0 + 0.12.15