Compare commits

...

2 Commits

Author SHA1 Message Date
4de9e1865c Add listOfSpec delegate to Scheme 2023-12-19 17:53:17 +03:00
a32cbe95dc Add listOfSpec delegate to Scheme 2023-12-19 17:53:01 +03:00
3 changed files with 13 additions and 8 deletions

View File

@ -8,7 +8,7 @@ plugins {
allprojects { allprojects {
group = "space.kscience" group = "space.kscience"
version = "0.7.1" version = "0.7.2-dev-1"
} }
subprojects { subprojects {

View File

@ -128,3 +128,10 @@ public fun <T : Scheme> MutableMeta.listOfSpec(
setIndexed(name, value.map { it.toMeta() }) setIndexed(name, value.map { it.toMeta() })
} }
} }
@DFExperimental
public fun <T : Scheme> Scheme.listOfSpec(
spec: Specification<T>,
key: Name? = null,
): ReadWriteProperty<Any?, List<T>> = meta.listOfSpec(spec, key)

View File

@ -16,13 +16,11 @@ public class Name(public val tokens: List<NameToken>) {
override fun toString(): String = tokens.joinToString(separator = NAME_SEPARATOR) { it.toString() } override fun toString(): String = tokens.joinToString(separator = NAME_SEPARATOR) { it.toString() }
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean = when (other) {
return when (other) {
is Name -> this.tokens == other.tokens is Name -> this.tokens == other.tokens
is NameToken -> this.length == 1 && this.tokens.first() == other is NameToken -> this.length == 1 && this.tokens.first() == other
else -> false else -> false
} }
}
private val cachedHashCode = if (tokens.size == 1) { private val cachedHashCode = if (tokens.size == 1) {
tokens.first().hashCode() tokens.first().hashCode()