add append methods for meta
This commit is contained in:
parent
5fbbac465a
commit
4a76063093
@ -384,19 +384,25 @@ private class MutableMetaImpl(
|
|||||||
* Append the node with a same-name-sibling, automatically generating numerical index
|
* Append the node with a same-name-sibling, automatically generating numerical index
|
||||||
*/
|
*/
|
||||||
@DFExperimental
|
@DFExperimental
|
||||||
public fun MutableMeta.append(name: Name, value: Value?) {
|
public fun MutableMeta.append(name: Name, meta: Meta) {
|
||||||
require(!name.isEmpty()) { "Name could not be empty for append operation" }
|
require(!name.isEmpty()) { "Name could not be empty for append operation" }
|
||||||
val newIndex = name.lastOrNull()!!.index
|
val newIndex = name.lastOrNull()!!.index
|
||||||
if (newIndex != null) {
|
if (newIndex != null) {
|
||||||
set(name, value)
|
set(name, meta)
|
||||||
} else {
|
} else {
|
||||||
val index = (getIndexed(name).keys.mapNotNull { it?.toIntOrNull() }.maxOrNull() ?: -1) + 1
|
val index = (getIndexed(name).keys.mapNotNull { it?.toIntOrNull() }.maxOrNull() ?: -1) + 1
|
||||||
set(name.withIndex(index.toString()), value)
|
set(name.withIndex(index.toString()), meta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DFExperimental
|
@DFExperimental
|
||||||
public fun MutableMeta.append(name: String, value: Value?): Unit = append(name.toName(), value)
|
public fun MutableMeta.append(name: String, meta: Meta): Unit = append(name.toName(), meta)
|
||||||
|
|
||||||
|
@DFExperimental
|
||||||
|
public fun MutableMeta.append(name: Name, value: Value): Unit = append(name, Meta(value))
|
||||||
|
|
||||||
|
@DFExperimental
|
||||||
|
public fun MutableMeta.append(name: String, value: Value): Unit = append(name.toName(), value)
|
||||||
|
|
||||||
///**
|
///**
|
||||||
// * Apply existing node with given [builder] or create a new element with it.
|
// * Apply existing node with given [builder] or create a new element with it.
|
||||||
|
Loading…
Reference in New Issue
Block a user