All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.StartPluginSerializer.jvm.kt Maven / Gradle / Ivy

There is a newer version: 0.23.0
Show newest version
package dev.inmo.micro_utils.startup.plugin

import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

internal actual fun alternativeDeserialize(decoder: Decoder): StartPlugin? {
    val kclass = Class.forName(decoder.decodeString()).kotlin
    return (kclass.objectInstance ?: kclass.constructors.first { it.parameters.isEmpty() }.call()) as StartPlugin
}

internal actual fun alternativeSerialize(
    encoder: Encoder,
    value: StartPlugin
): Boolean {
    encoder.encodeString(value::class.java.canonicalName ?: return false)
    return true
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy