Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin wrapper for the Java library #92

Open
purrgrammer opened this issue Feb 14, 2020 · 1 comment
Open

Kotlin wrapper for the Java library #92

purrgrammer opened this issue Feb 14, 2020 · 1 comment

Comments

@purrgrammer
Copy link
Contributor

purrgrammer commented Feb 14, 2020

Like memeid-scala, which wraps our UUID type with an idiomatic API for the language.

@ahinchman1
Copy link

It'd be really nice to add compatibility kotlin extensions for serialization. It currently doesn't exist for UUIDs but could be acheived using a small wrapper class. Something like:

@Serializer(forClass = UUID::class)
    object UUIDSerializer : KSerializer<UUID> {
        override val descriptor: SerialDescriptor
            get() = StringDescriptor.withName("UUID")

        override fun serialize(output: Encoder, obj: UUID) {
            output.encodeString(obj.toString())
        }

        override fun deserialize(input: Decoder): UUID {
            return UUID.fromString(input.decode())
        }
    }

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants