Skip to content

Commit 1a1082a

Browse files
committed
fix issues
1 parent 35a92be commit 1a1082a

File tree

8 files changed

+34
-123
lines changed

8 files changed

+34
-123
lines changed

lombok.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
config.stopBubbling = true
22

3+
# Required for NullAway to work
34
lombok.addLombokGeneratedAnnotation = true
45

56
# Copy JSpecify annotations to generated code (constructors, getters, setters)

src/main/java/it/aboutbits/springboot/toolbox/exception/ConstraintViolationExceptionBuilder.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import jakarta.validation.metadata.ConstraintDescriptor;
77
import org.hibernate.validator.internal.engine.path.PathImpl;
88
import org.jspecify.annotations.NullMarked;
9-
import org.jspecify.annotations.NullUnmarked;
9+
import org.jspecify.annotations.Nullable;
1010

1111
import java.util.HashSet;
1212
import java.util.Set;
@@ -54,28 +54,32 @@ public boolean hasCauses() {
5454
return !constraintViolations.isEmpty();
5555
}
5656

57-
@NullUnmarked
58-
private record CustomConstraintViolation(String message, Path propertyPath) implements ConstraintViolation<Object> {
57+
@NullMarked
58+
public record CustomConstraintViolation(String message, Path propertyPath) implements ConstraintViolation<Object> {
5959
@Override
6060
public String getMessage() {
6161
return message;
6262
}
6363

64+
@Nullable
6465
@Override
6566
public String getMessageTemplate() {
6667
return null;
6768
}
6869

70+
@Nullable
6971
@Override
7072
public Object getRootBean() {
7173
return null;
7274
}
7375

76+
@Nullable
7477
@Override
7578
public Class<Object> getRootBeanClass() {
7679
return null;
7780
}
7881

82+
@Nullable
7983
@Override
8084
public Object getLeafBean() {
8185
return null;
@@ -86,6 +90,7 @@ public Object[] getExecutableParameters() {
8690
return new Object[0];
8791
}
8892

93+
@Nullable
8994
@Override
9095
public Object getExecutableReturnValue() {
9196
return null;
@@ -96,16 +101,19 @@ public Path getPropertyPath() {
96101
return propertyPath;
97102
}
98103

104+
@Nullable
99105
@Override
100106
public Object getInvalidValue() {
101107
return null;
102108
}
103109

110+
@Nullable
104111
@Override
105112
public ConstraintDescriptor<?> getConstraintDescriptor() {
106113
return null;
107114
}
108115

116+
@Nullable
109117
@Override
110118
public <U> U unwrap(Class<U> type) {
111119
return null;

src/main/java/it/aboutbits/springboot/toolbox/persistence/converter/UUIDConverter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
import jakarta.persistence.AttributeConverter;
44
import jakarta.persistence.Converter;
5-
import org.jspecify.annotations.NullUnmarked;
5+
import org.jspecify.annotations.NullMarked;
6+
import org.jspecify.annotations.Nullable;
67

78
import java.util.UUID;
89

910
@Converter
10-
@NullUnmarked
11+
@NullMarked
1112
public class UUIDConverter implements AttributeConverter<UUID, String> {
1213
@Override
13-
public String convertToDatabaseColumn(UUID attribute) {
14+
@Nullable
15+
public String convertToDatabaseColumn(@Nullable UUID attribute) {
1416
if (attribute == null) {
1517
return null;
1618
}
@@ -19,7 +21,8 @@ public String convertToDatabaseColumn(UUID attribute) {
1921
}
2022

2123
@Override
22-
public UUID convertToEntityAttribute(String dbData) {
24+
@Nullable
25+
public UUID convertToEntityAttribute(@Nullable String dbData) {
2326
if (dbData == null || dbData.isBlank()) {
2427
return null;
2528
}

src/main/java/it/aboutbits/springboot/toolbox/swagger/SwaggerMeta.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,34 @@
44
import com.fasterxml.jackson.annotation.JsonProperty;
55
import lombok.Getter;
66
import lombok.Setter;
7-
import org.jspecify.annotations.NullUnmarked;
7+
import org.jspecify.annotations.NullMarked;
8+
import org.jspecify.annotations.Nullable;
89

10+
// JsonProperty on boolean fields is required or it will interpret the name as a getter and remove the "is".
911
@Getter
1012
@Setter
1113
@JsonInclude(JsonInclude.Include.NON_NULL)
12-
@NullUnmarked
14+
@NullMarked
1315
public class SwaggerMeta {
16+
@Nullable
1417
private String originalTypeFqn = null;
18+
19+
@Nullable
1520
@JsonProperty("isIdentity")
1621
private Boolean isIdentity = null;
22+
23+
@Nullable
1724
@JsonProperty("isCustomType")
1825
private Boolean isCustomType = null;
26+
27+
@Nullable
1928
@JsonProperty("isNestedStructure")
2029
private Boolean isNestedStructure = null;
30+
31+
@Nullable
2132
@JsonProperty("isMap")
2233
private Boolean isMap = null;
34+
35+
@Nullable
2336
private String mapKeyTypeFqn = null;
2437
}

src/main/java/it/aboutbits/springboot/toolbox/type/ScaledBigDecimal.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ public ScaledBigDecimal roundToScale(int scale) {
188188
}
189189

190190
@Override
191-
192191
public String toString() {
193192
return this.value().toString();
194193
}
@@ -221,7 +220,6 @@ public int compareTo(ScaledBigDecimal o) {
221220
* This is temporary. We need to avoid changing any rounding logic at the moment.
222221
*/
223222
@Deprecated
224-
225223
public BigDecimal toCurrency() {
226224
return this.value().setScale(2, RoundingMode.HALF_UP);
227225
}
@@ -231,7 +229,6 @@ public BigDecimal toCurrency() {
231229
* This is temporary. We need to avoid changing any rounding logic at the moment.
232230
*/
233231
@Deprecated
234-
235232
public ScaledBigDecimal roundToCurrency() {
236233
return new ScaledBigDecimal(this.value().setScale(2, RoundingMode.HALF_UP));
237234
}

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/test/java/it/aboutbits/springboot/toolbox/util/NullUtilTest.java

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/test/java/it/aboutbits/springboot/toolbox/web/SortParameterResolverTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class SortParameterResolverTest {
4242
@InjectMocks
4343
private SortParameterResolver sut;
4444

45-
@SuppressWarnings("NullAway.Init")
4645
@BeforeEach
4746
void setUp() {
4847
when(methodParameter.getParameterName()).thenReturn("sort");

0 commit comments

Comments
 (0)