diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/json/MappedTypeFactories.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/json/MappedTypeFactories.kt deleted file mode 100644 index ff94789f..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/io/json/MappedTypeFactories.kt +++ /dev/null @@ -1,26 +0,0 @@ -package ru.dbotthepony.kstarbound.io.json - -import com.google.gson.Gson -import com.google.gson.TypeAdapter -import com.google.gson.TypeAdapterFactory -import com.google.gson.reflect.TypeToken -import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap - -class MappedTypeFactories : TypeAdapterFactory { - private val adapters = Reference2ObjectOpenHashMap, TypeAdapterFactory>() - - fun put(clazz: Class, adapter: TypeAdapterFactory): MappedTypeFactories { - check(adapters.put(clazz, adapter) == null) { "Already had type adapter for $clazz" } - return this - } - - override fun create(gson: Gson, type: TypeToken): TypeAdapter? { - val factory = adapters[type.rawType] - - if (factory != null) { - return checkNotNull(factory.create(gson, type)) { "${type.rawType} should have type adapter (factory: $factory)" } - } - - return null - } -}