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,55 +15,55 @@ 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){
set(this,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<*>){
infix fun String.put(enum: Enum<*>) {
set(this, EnumValue(enum))
}
@JvmName("putValues")
infix fun String.put(iterable: Iterable<Value>){
infix fun String.put(iterable: Iterable<Value>) {
set(this, iterable.asValue())
}
@JvmName("putNumbers")
infix fun String.put(iterable: Iterable<Number>){
infix fun String.put(iterable: Iterable<Number>) {
set(this, iterable.map { it.asValue() }.asValue())
}
@JvmName("putStrings")
infix fun String.put(iterable: Iterable<String>){
infix fun String.put(iterable: Iterable<String>) {
set(this, iterable.map { it.asValue() }.asValue())
}
infix fun String.put(array: DoubleArray){
infix fun String.put(array: DoubleArray) {
set(this, array.asValue())
}
infix fun String.putValue(any: Any?){
infix fun String.putValue(any: Any?) {
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,37 +75,37 @@ class MetaBuilder : AbstractMutableMeta<MetaBuilder>() {
this@MetaBuilder[this] = MetaBuilder().apply(metaBuilder)
}
infix fun Name.put(value: Value){
set(this,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<*>){
infix fun Name.put(enum: Enum<*>) {
set(this, EnumValue(enum))
}
@JvmName("putValues")
infix fun Name.put(iterable: Iterable<Value>){
infix fun Name.put(iterable: Iterable<Value>) {
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")