serialization.SerializationFormat.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hexagon_core Show documentation
Show all versions of hexagon_core Show documentation
Hexagon core utilities. Includes serialization and logging helpers.
The newest version!
package com.hexagonkt.serialization
import java.io.ByteArrayOutputStream
import java.io.InputStream
import java.io.OutputStream
import kotlin.reflect.KClass
interface SerializationFormat {
val contentType: String
val extensions: Set
val isBinary: Boolean
fun serialize(obj: Any, output: OutputStream)
fun parse(input: InputStream, type: KClass): T
fun parseObjects(input: InputStream, type: KClass): List
fun serialize(obj: Any): String =
if (isBinary) error("$contentType is a binary format")
else ByteArrayOutputStream().let {
serialize(obj, it)
it.toString()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy