All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.jetbrains.datalore.base.json.FluentArray.kt Maven / Gradle / Ivy

There is a newer version: 4.5.3-alpha1
Show newest version
/*
 * Copyright (c) 2020. JetBrains s.r.o.
 * Use of this source code is governed by the MIT license that can be found in the LICENSE file.
 */

package jetbrains.datalore.base.json


class FluentArray: FluentValue {
    private val myArray: ArrayList

    constructor() {
        myArray = ArrayList()
    }

    constructor(array: List) {
        myArray = ArrayList(array)
    }

    fun getDouble(index: Int) = myArray[index] as Double

    fun add(v: String?) = apply { myArray.add(v) }
    fun add(v: Double?) = apply { myArray.add(v) }
    fun addStrings(values: List) = apply { myArray.addAll(values) }
    fun addAll(values: List) = apply { values.forEach { v -> myArray.add(v.get()) } }
    fun addAll(vararg values: FluentValue) = apply { addAll(listOf(*values)) }

    fun stream() = streamOf(myArray)
    fun objectStream() = objectsStreamOf(myArray)
    fun fluentObjectStream() = objectsStreamOf(myArray).map(::FluentObject)

    override fun get() = myArray
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy