Skip to content

Commit

Permalink
Add legacy chromoa colour to default gson mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
nea89o committed Jan 11, 2024
1 parent e16585f commit 4291b35
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package io.github.moulberry.moulconfig.managed

import com.google.gson.GsonBuilder
import io.github.moulberry.moulconfig.ChromaColour
import io.github.moulberry.moulconfig.LegacyStringChromaColourTypeAdapter
import io.github.moulberry.moulconfig.observer.PropertyTypeAdapterFactory

class GsonMapper<T>(val clazz: Class<T>) : DataMapper<T> {
val gsonBuilder = GsonBuilder()
.registerTypeAdapterFactory(PropertyTypeAdapterFactory())
.registerTypeAdapter(ChromaColour::class.java, LegacyStringChromaColourTypeAdapter(true))
private val gson by lazy { gsonBuilder.create() }
override fun serialize(value: T): String {
return gson.toJson(value)
Expand Down

0 comments on commit 4291b35

Please sign in to comment.