Make putted values optional in MetaBuilder

This commit is contained in:
Alexander Nozik 2019-10-30 17:13:31 +03:00
parent 84c5f6d925
commit ade4eec96e

View File

@ -15,20 +15,20 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
override fun wrapNode(meta: Meta): MetaBuilder = if (meta is MetaBuilder) meta else meta.builder()
override fun empty(): MetaBuilder = MetaBuilder()
infix fun String.put(value: Value){
infix fun String.put(value: Value?) {
set(this, value)
}
infix fun String.put(string: String){
set(this,string.asValue())
infix fun String.put(string: String?) {
set(this, string?.asValue())
}
infix fun String.put(number: Number){
set(this,number.asValue())
infix fun String.put(number: Number?) {
set(this, number?.asValue())
}
infix fun String.put(boolean: Boolean){
set(this, boolean.asValue())
infix fun String.put(boolean: Boolean?) {
set(this, boolean?.asValue())
}
infix fun String.put(enum: Enum<*>) {
@ -58,12 +58,12 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
set(this, Value.of(any))
}
infix fun String.put(meta: Meta) {
infix fun String.put(meta: Meta?) {
this@MetaBuilder[this] = meta
}
infix fun String.put(repr: MetaRepr){
set(this,repr.toMeta())
infix fun String.put(repr: MetaRepr?) {
set(this, repr?.toMeta())
}
@JvmName("putMetas")
@ -75,20 +75,20 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
}
infix fun Name.put(value: Value){
infix fun Name.put(value: Value?) {
set(this, value)
}
infix fun Name.put(string: String){
set(this,string.asValue())
infix fun Name.put(string: String?) {
set(this, string?.asValue())
}
infix fun Name.put(number: Number){
set(this,number.asValue())
infix fun Name.put(number: Number?) {
set(this, number?.asValue())
}
infix fun Name.put(boolean: Boolean){
set(this, boolean.asValue())
infix fun Name.put(boolean: Boolean?) {
set(this, boolean?.asValue())
}
infix fun Name.put(enum: Enum<*>) {
@ -100,12 +100,12 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
set(this, iterable.asValue())
}
infix fun Name.put(meta: Meta) {
infix fun Name.put(meta: Meta?) {
this@MetaBuilder[this] = meta
}
infix fun Name.put(repr: MetaRepr){
set(this,repr.toMeta())
infix fun Name.put(repr: MetaRepr?) {
set(this, repr?.toMeta())
}
@JvmName("putMetas")