forked from oncokb/oncokb-transcript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize Gson with custom Instance serializer
Since Instant is immutable in Java 17, we need to implement serialize and de-serialize methods to convert Instant object into gson.
- Loading branch information
Showing
4 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
src/main/java/org/mskcc/oncokb/curation/util/GsonUtils.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,14 @@ | ||
package org.mskcc.oncokb.curation.util; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import java.time.Instant; | ||
import org.mskcc.oncokb.curation.config.InstantTypeAdapter; | ||
|
||
public class GsonUtils { | ||
|
||
public static Gson create() { | ||
// https://medium.com/@pratiktikarye/instant-to-gson-conversion-in-java-17-2673bb59fbea | ||
return new GsonBuilder().registerTypeAdapter(Instant.class, new InstantTypeAdapter()).create(); | ||
} | ||
} |