jvmMain.it.unibo.tuprolog.serialize.WritingSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serialize-core-jvm Show documentation
Show all versions of serialize-core-jvm Show documentation
JSON and YAML serialization support for logic terms and clauses
The newest version!
package it.unibo.tuprolog.serialize
import java.io.StringWriter
import java.io.Writer
interface WritingSerializer : Serializer {
fun serialize(
writer: Writer,
value: T,
)
override fun serialize(value: T): String =
StringWriter().use {
serialize(it, value)
it.toString()
}
fun serializeMany(
writer: Writer,
vararg values: T,
) = serializeMany(writer, listOf(*values))
fun serializeMany(
writer: Writer,
values: Iterable,
)
override fun serializeMany(values: Iterable): String =
StringWriter().use {
serializeMany(it, values)
it.toString()
}
fun serializeMany(
writer: Writer,
values: Sequence,
) = serializeMany(writer, values.asIterable())
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy