Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
44 changes: 17 additions & 27 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>3.5.7</version>
<version>4.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -52,7 +53,7 @@
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>4.8.181</version>
<version>4.8.184</version>
</dependency>


Expand All @@ -61,7 +62,7 @@
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
Expand All @@ -78,7 +79,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.14</version>
<version>3.0.0</version>
</dependency>

<!-- Testing -->
Expand All @@ -98,13 +99,18 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>

<!-- Database -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-liquibase</artifactId>
<scope>test</scope>
</dependency>

<!-- Database -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand All @@ -117,22 +123,6 @@
<artifactId>testcontainers</artifactId>
<version>2.0.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</exclusion>
<exclusion>
<!-- see: https://github.com/testcontainers/testcontainers-java/issues/970#issuecomment-625044008 -->
<!-- can be removed once testcontainers drop their dependency to junit4 -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand Down Expand Up @@ -195,12 +185,12 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>11.1.0</version>
<version>12.3.0</version>
</dependency>
<dependency>
<groupId>it.aboutbits</groupId>
<artifactId>java-checkstyle-config</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import it.aboutbits.springboot.toolbox.type.identity.EntityId;
import it.aboutbits.springboot.toolbox.web.CustomTypePropertyEditor;
import it.aboutbits.springboot.toolbox.web.EntityIdPropertyEditor;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
import tools.jackson.databind.module.SimpleModule;

import java.util.Set;

Expand All @@ -37,19 +38,23 @@ public void initBinder(WebDataBinder binder) {
}

@Bean
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuration) {
var types = configuration.getRelevantTypes();
public JsonMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuration) {
var module = new SimpleModule();

var deserializers = types.stream()
.map(CustomTypeDeserializer::new)
.toList()
.toArray(new CustomTypeDeserializer[types.size()]);
// serializers
module.addSerializer(new CustomTypeSerializer());

// dynamic deserializers
configuration.getRelevantTypes()
.forEach(type ->
module.addDeserializer(type, new CustomTypeDeserializer(type))
);
Comment on lines +49 to +51

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please auto-format all files.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reformatted a few things, but not that one 🤷


// type-based deserializer
module.addDeserializer(EntityId.class, new EntityIdDeserializer());

return builder -> builder
.serializers(new CustomTypeSerializer())
.deserializers(deserializers)
.deserializerByType(EntityId.class, new EntityIdDeserializer());
.addModule(module);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* <p>
* Example:
* {@snippet :
*
* @Getter
* @Accessors(fluent = true)
* @RequiredArgsConstructor
* enum MyExceptionMessages implements ExceptionMessageDefinition {
* SHARED_ERROR_GENERAL("shared.error.general");
*
* private final String code;
* }
* @RequiredArgsConstructor enum MyExceptionMessages implements ExceptionMessageDefinition {
* SHARED_ERROR_GENERAL("shared.error.general");
* <p>
* private final String code;
* }
*}
*/
public interface ExceptionMessageDefinition {
String code();
Expand Down
Loading