-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0a7a0a
commit fe70e5a
Showing
7 changed files
with
116 additions
and
42 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/java/ru/olegcherednik/json/jackson/JacksonSimpleModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package ru.olegcherednik.json.jackson; | ||
|
||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.module.SimpleDeserializers; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
import com.fasterxml.jackson.databind.module.SimpleSerializers; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @author Oleg Cherednik | ||
* @since 18.02.2024 | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class JacksonSimpleModule extends SimpleModule { | ||
|
||
private static final long serialVersionUID = -543871656247679655L; | ||
|
||
@Override | ||
public void setupModule(SetupContext context) { | ||
super.setupModule(context); | ||
|
||
addKeySerializers(context); | ||
addKeyDeserializers(context); | ||
|
||
addSerializers(context); | ||
addDeserializers(context); | ||
} | ||
|
||
protected void addKeySerializers(SetupContext context) { | ||
} | ||
|
||
protected void addKeyDeserializers(SetupContext context) { | ||
} | ||
|
||
protected void addSerializers(SetupContext context) { | ||
} | ||
|
||
protected void addDeserializers(SetupContext context) { | ||
} | ||
|
||
protected static <T> SimpleSerializers createSerializers(JsonSerializer<T> serializer) { | ||
SimpleSerializers serializers = new SimpleSerializers(); | ||
serializers.addSerializer(serializer.handledType(), serializer); | ||
return serializers; | ||
} | ||
|
||
protected static <T> SimpleDeserializers createDeserializers(JsonDeserializer<T> deserializer) { | ||
SimpleDeserializers deserializers = new SimpleDeserializers(); | ||
deserializers.addDeserializer((Class<T>) deserializer.handledType(), deserializer); | ||
return deserializers; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters