ненужно
This commit is contained in:
parent
be87ca7cc1
commit
a4f4320b04
@ -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<Class<*>, TypeAdapterFactory>()
|
||||
|
||||
fun <T> put(clazz: Class<T>, adapter: TypeAdapterFactory): MappedTypeFactories {
|
||||
check(adapters.put(clazz, adapter) == null) { "Already had type adapter for $clazz" }
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <T : Any?> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
|
||||
val factory = adapters[type.rawType]
|
||||
|
||||
if (factory != null) {
|
||||
return checkNotNull(factory.create(gson, type)) { "${type.rawType} should have type adapter (factory: $factory)" }
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user