Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config.stopBubbling = true

lombok.addLombokGeneratedAnnotation = true

# Copy JSpecify annotations to generated code (constructors, getters, setters)
lombok.copyableAnnotations += org.jspecify.annotations.Nullable
lombok.copyableAnnotations += org.jspecify.annotations.NonNull
lombok.addNullAnnotations = jspecify
66 changes: 64 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.0</version>
<version>4.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -17,8 +18,20 @@

<properties>
<java.version>25</java.version>
<errorprone.version>2.45.0</errorprone.version>
<nullaway.version>0.12.14</nullaway.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>it.aboutbits</groupId>
<artifactId>archunit-toolbox</artifactId>
<version>1.0.0-RC1</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -135,6 +148,26 @@
<version>2.0.2</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.tngtech.archunit/archunit-junit5 -->
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
<version>1.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5-api</artifactId>
<version>1.4.1</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>it.aboutbits</groupId>
<artifactId>archunit-toolbox</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -156,7 +189,36 @@
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${errorprone.version}</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>${nullaway.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amapstruct.unmappedTargetPolicy=ERROR</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>--should-stop=ifError=FLOW</arg>
<!-- @formatter:off -->
<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>
<!-- @formatter:on -->
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType;
import org.jspecify.annotations.NullMarked;

import java.lang.reflect.InvocationTargetException;
import java.util.Set;

@NullMarked
public abstract class AbstractCustomTypeContributor implements TypeContributor {
@SuppressWarnings("rawtypes")
private final Set<Class<? extends AutoRegisteredJavaType>> relevantTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package it.aboutbits.springboot.toolbox.autoconfiguration.persistence;

import org.hibernate.type.descriptor.java.JavaType;
import org.jspecify.annotations.NullMarked;

@NullMarked
public interface AutoRegisteredJavaType<T> extends JavaType<T> {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.aboutbits.springboot.toolbox.autoconfiguration.persistence;

import org.jspecify.annotations.NullMarked;

@NullMarked
public final class CustomTypeContributor extends AbstractCustomTypeContributor {
public CustomTypeContributor() {
super("it.aboutbits.springboot.toolbox");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import it.aboutbits.springboot.toolbox.type.identity.EntityId;
import it.aboutbits.springboot.toolbox.web.CustomTypePropertyEditor;
import it.aboutbits.springboot.toolbox.web.EntityIdPropertyEditor;
import org.jspecify.annotations.NullMarked;
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -18,6 +19,7 @@
import java.util.Set;

@Configuration
@NullMarked
public class CustomTypeConfiguration {
@ControllerAdvice
public static class CustomTypePropertyBinder {
Expand Down Expand Up @@ -46,8 +48,8 @@ public JsonMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuratio

// dynamic deserializers
configuration.getRelevantTypes()
.forEach(type ->
module.addDeserializer(type, new CustomTypeDeserializer(type))
.forEach(
type -> module.addDeserializer(type, new CustomTypeDeserializer(type))
);

// type-based deserializer
Expand All @@ -56,5 +58,4 @@ public JsonMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuratio
return builder -> builder
.addModule(module);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import it.aboutbits.springboot.toolbox.type.CustomType;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.jspecify.annotations.NullMarked;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -18,6 +19,7 @@

@Slf4j
@Getter
@NullMarked
public class CustomTypeScanner {
private static final String LIBRARY_BASE_PACKAGE_NAME = "it.aboutbits.springboot.toolbox";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.toolbox.autoconfiguration.web;

import org.jspecify.annotations.NullMarked;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
Expand All @@ -8,6 +9,7 @@

import java.util.Objects;

@NullMarked
public class CustomTypeScannerRegistrar implements ImportBeanDefinitionRegistrar {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.aboutbits.springboot.toolbox.autoconfiguration.web;

import org.jspecify.annotations.NullMarked;
import org.springframework.context.annotation.Import;

import java.lang.annotation.ElementType;
Expand All @@ -10,6 +11,7 @@
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Import({CustomTypeScannerRegistrar.class, CustomTypeConfiguration.class})
@NullMarked
public @interface RegisterCustomTypesWithJacksonAndMvc {
String[] additionalTypePackages() default "";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.aboutbits.springboot.toolbox.exception;

import org.jspecify.annotations.NullMarked;

@NullMarked
public class ClientRuntimeException extends RuntimeException {
public ClientRuntimeException() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,57 @@
import jakarta.validation.ConstraintViolationException;
import jakarta.validation.Path;
import jakarta.validation.metadata.ConstraintDescriptor;
import lombok.NonNull;
import org.hibernate.validator.internal.engine.path.PathImpl;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.NullUnmarked;

import java.util.HashSet;
import java.util.Set;

@NullMarked
public final class ConstraintViolationExceptionBuilder {
private final Set<ConstraintViolation<?>> constraintViolations = new HashSet<>();

private ConstraintViolationExceptionBuilder() {

}

@SuppressWarnings("unused")
public static ConstraintViolationExceptionBuilder constraintViolation() {
return new ConstraintViolationExceptionBuilder();
}

@SuppressWarnings("unused")
public ConstraintViolationExceptionBuilder causedBy(
@NonNull String propertyPath,
@NonNull ExceptionMessageDefinition message
String propertyPath,
ExceptionMessageDefinition message
) {
return causedBy(propertyPath, message.code());
}

public ConstraintViolationExceptionBuilder causedBy(@NonNull String propertyPath, @Nullable String message) {
@SuppressWarnings({"unused", "UnusedReturnValue"})
public ConstraintViolationExceptionBuilder causedBy(String propertyPath, String message) {
var constraintViolation = new CustomConstraintViolation(message, PathImpl.createPathFromString(propertyPath));
constraintViolations.add(constraintViolation);
return this;
}

public ConstraintViolationExceptionBuilder causedBy(@NonNull ConstraintViolationException e) {
@SuppressWarnings({"unused", "UnusedReturnValue"})
public ConstraintViolationExceptionBuilder causedBy(ConstraintViolationException e) {
constraintViolations.addAll(e.getConstraintViolations());
return this;
}

@SuppressWarnings("unused")
public ConstraintViolationException create() {
return new ConstraintViolationException(constraintViolations);
}

@SuppressWarnings("unused")
public boolean hasCauses() {
return !constraintViolations.isEmpty();
}

@NullUnmarked
private record CustomConstraintViolation(String message, Path propertyPath) implements ConstraintViolation<Object> {
@Override
public String getMessage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package it.aboutbits.springboot.toolbox.exception;

import org.jspecify.annotations.NullMarked;

/**
* Use this to create a class or enum that defines the exception messages.
* This way, the messages can be referenced by a constant rather than using plain strings.
Expand All @@ -16,6 +18,7 @@
* }
*}
*/
@NullMarked
public interface ExceptionMessageDefinition {
String code();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package it.aboutbits.springboot.toolbox.exception;

import org.jspecify.annotations.NullMarked;

@NullMarked
public class ServerRuntimeException extends RuntimeException {
public ServerRuntimeException() {
}
Expand Down
Loading