-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
18 deletions.
There are no files selected for viewing
18 changes: 0 additions & 18 deletions
18
src/main/java/xyz/xenondevs/nova/serialization/gson/EnumMapInstanceCreator.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/xyz/xenondevs/nova/serialization/gson/EnumMapInstanceCreator.kt
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,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<*>) | ||
} | ||
|
||
} |