Skip to content

Commit

Permalink
Made EnumMapInstanceCreator kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZ1337 committed Jun 26, 2021
1 parent 4ead274 commit c94af73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package xyz.xenondevs.nova.serialization.gson

import com.google.gson.InstanceCreator
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type
import java.util.*

private val ENUMMAP_CONSTRUCTOR = EnumMap::class.java.getConstructor(Class::class.java)

class EnumMapInstanceCreator : InstanceCreator<EnumMap<*, *>> {

// https://stackoverflow.com/questions/54966118/how-to-deserialize-an-enummap
override fun createInstance(type: Type): EnumMap<*, *> {
return ENUMMAP_CONSTRUCTOR.newInstance((type as ParameterizedType).actualTypeArguments[0] as Class<*>)
}

}

0 comments on commit c94af73

Please sign in to comment.