
commonMain.space.kscience.dataforge.data.NamedData.kt Maven / Gradle / Ivy
package space.kscience.dataforge.data
import space.kscience.dataforge.meta.isEmpty
import space.kscience.dataforge.misc.Named
import space.kscience.dataforge.names.Name
public interface NamedData : Named, Data {
override val name: Name
public val data: Data
}
private class NamedDataImpl(
override val name: Name,
override val data: Data,
) : Data by data, NamedData {
override fun toString(): String = buildString {
append("NamedData(name=\"$name\"")
if (data is StaticData) {
append(", value=${data.value}")
}
if (!data.meta.isEmpty()) {
append(", meta=${data.meta}")
}
append(")")
}
}
public fun Data.named(name: Name): NamedData = if (this is NamedData) {
NamedDataImpl(name, this.data)
} else {
NamedDataImpl(name, this)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy