Skip to content

Commit 35a92be

Browse files
committed
fixes and archunit
1 parent a59e753 commit 35a92be

18 files changed

Lines changed: 107 additions & 615 deletions

File tree

pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>4.0.0</version>
9+
<version>4.0.1</version>
1010
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

@@ -22,6 +22,16 @@
2222
<nullaway.version>0.12.14</nullaway.version>
2323
</properties>
2424

25+
<dependencyManagement>
26+
<dependencies>
27+
<dependency>
28+
<groupId>it.aboutbits</groupId>
29+
<artifactId>archunit-toolbox</artifactId>
30+
<version>1.0.0-RC1</version>
31+
</dependency>
32+
</dependencies>
33+
</dependencyManagement>
34+
2535
<dependencies>
2636
<dependency>
2737
<groupId>org.springframework.boot</groupId>
@@ -152,6 +162,12 @@
152162
<version>1.4.1</version>
153163
<scope>compile</scope>
154164
</dependency>
165+
166+
<dependency>
167+
<groupId>it.aboutbits</groupId>
168+
<artifactId>archunit-toolbox</artifactId>
169+
<scope>test</scope>
170+
</dependency>
155171
</dependencies>
156172

157173
<build>
@@ -189,7 +205,7 @@
189205
<arg>-XDcompilePolicy=simple</arg>
190206
<arg>--should-stop=ifError=FLOW</arg>
191207
<!-- @formatter:off -->
192-
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -XepOpt:NullAway:AnnotatedPackages=it.aboutbits.springbootboilerplate -XepOpt:NullAway:JSpecifyMode=true -Xep:NullAway:ERROR</arg>
208+
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -XepOpt:NullAway:AnnotatedPackages=it.aboutbits.springboot.toolbox -XepOpt:NullAway:JSpecifyMode=true -Xep:NullAway:ERROR -XepOpt:NullAway:ExcludedFieldAnnotations=org.mockito.InjectMocks,org.mockito.Mock</arg>
193209
<!-- @formatter:on -->
194210
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
195211
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package it.aboutbits.springboot.toolbox.type.identity;
22

33
import org.jspecify.annotations.NullMarked;
4+
import org.jspecify.annotations.Nullable;
45

56
@NullMarked
67
public interface Identified<ID extends EntityId<?>> {
8+
@Nullable
79
ID getId();
810
}

src/main/java/it/aboutbits/springboot/toolbox/util/CollectUtil.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,72 +24,72 @@ public final class CollectUtil {
2424
private CollectUtil() {
2525
}
2626

27-
public static <T, R> Set<R> collectToSet(Collection<T> items, Function<T, @Nullable R> mapper) {
27+
public static <T, R> Set<R> collectToSet(Collection<T> items, NullableFunction<? super T, R> mapper) {
2828
return items.stream()
29-
.map(mapper)
29+
.map(mapper::apply)
3030
.filter(Objects::nonNull)
3131
.collect(Collectors.toUnmodifiableSet());
3232
}
3333

34-
public static <T, R> Set<R> collectToSet(Streamable<T> items, Function<T, @Nullable R> mapper) {
34+
public static <T, R> Set<R> collectToSet(Streamable<T> items, NullableFunction<? super T, R> mapper) {
3535
return items.stream()
36-
.map(mapper)
36+
.map(mapper::apply)
3737
.filter(Objects::nonNull)
3838
.collect(Collectors.toUnmodifiableSet());
3939
}
4040

41-
public static <T, R> Set<R> collectToSet(Stream<T> items, Function<T, @Nullable R> mapper) {
41+
public static <T, R> Set<R> collectToSet(Stream<T> items, NullableFunction<? super T, R> mapper) {
4242
return items
43-
.map(mapper)
43+
.map(mapper::apply)
4444
.filter(Objects::nonNull)
4545
.collect(Collectors.toUnmodifiableSet());
4646
}
4747

4848
@SuppressWarnings("java:S6204")
49-
public static <T, R> List<R> collectToList(Collection<T> items, Function<T, @Nullable R> mapper) {
49+
public static <T, R> List<R> collectToList(Collection<T> items, NullableFunction<? super T, R> mapper) {
5050
//noinspection SimplifyStreamApiCallChains
5151
return items.stream()
52-
.map(mapper)
52+
.map(mapper::apply)
5353
.filter(Objects::nonNull)
5454
.collect(Collectors.toUnmodifiableList());
5555
}
5656

5757
@SuppressWarnings("java:S6204")
58-
public static <T, R> List<R> collectToList(Streamable<T> items, Function<T, @Nullable R> mapper) {
58+
public static <T, R> List<R> collectToList(Streamable<T> items, NullableFunction<? super T, R> mapper) {
5959
//noinspection SimplifyStreamApiCallChains
6060
return items.stream()
61-
.map(mapper)
61+
.map(mapper::apply)
6262
.filter(Objects::nonNull)
6363
.collect(Collectors.toUnmodifiableList());
6464
}
6565

6666
@SuppressWarnings("java:S6204")
67-
public static <T, R> List<R> collectToList(Stream<T> items, Function<T, @Nullable R> mapper) {
67+
public static <T, R> List<R> collectToList(Stream<T> items, NullableFunction<? super T, R> mapper) {
6868
//noinspection SimplifyStreamApiCallChains
6969
return items
70-
.map(mapper)
70+
.map(mapper::apply)
7171
.filter(Objects::nonNull)
7272
.collect(Collectors.toUnmodifiableList());
7373
}
7474

75-
public static <T, R> Stream<R> collectToStream(Collection<T> items, Function<T, @Nullable R> mapper) {
75+
public static <T, R> Stream<R> collectToStream(Collection<T> items, NullableFunction<? super T, R> mapper) {
7676
//noinspection NullableProblems
7777
return items.stream()
78-
.map(mapper)
78+
.map(mapper::apply)
7979
.filter(Objects::nonNull);
8080
}
8181

82-
public static <T, R> Stream<R> collectToStream(Streamable<T> items, Function<T, @Nullable R> mapper) {
82+
public static <T, R> Stream<R> collectToStream(Streamable<T> items, NullableFunction<? super T, R> mapper) {
8383
//noinspection NullableProblems
8484
return items.stream()
85-
.map(mapper)
85+
.map(mapper::apply)
8686
.filter(Objects::nonNull);
8787
}
8888

89-
public static <T, R> Stream<R> collectToStream(Stream<T> items, Function<T, @Nullable R> mapper) {
89+
public static <T, R> Stream<R> collectToStream(Stream<T> items, NullableFunction<? super T, R> mapper) {
9090
//noinspection NullableProblems
9191
return items
92-
.map(mapper)
92+
.map(mapper::apply)
9393
.filter(Objects::nonNull);
9494
}
9595

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package it.aboutbits.springboot.toolbox.util;
2+
3+
import org.jspecify.annotations.NullMarked;
4+
import org.jspecify.annotations.Nullable;
5+
6+
@NullMarked
7+
@FunctionalInterface
8+
public interface NullableFunction<T, R> {
9+
@Nullable R apply(T t);
10+
}

0 commit comments

Comments
 (0)