pl.allegro.mobile.logic.ClientLogicOperator.kt Maven / Gradle / Ivy
package pl.allegro.mobile.logic
internal open class ClientLogicOperator internal constructor(
val name: String,
val arguments: List = emptyList()
) : ClientLogicElement, ClientLogicArray {
internal constructor(name: String, vararg arguments: ClientLogicElement) : this(name, arguments.toList())
internal class Builder(private val name: String) {
private val arguments = mutableListOf()
fun add(element: ClientLogicElement) = apply {
arguments.add(element)
}
fun addIfNotNull(element: ClientLogicElement?) = apply {
element?.let { arguments.add(element) }
}
fun addAll(elements: List) = apply {
arguments.addAll(elements)
}
fun addAll(elements: Array) = apply {
arguments.addAll(elements)
}
fun build() = ClientLogicOperator(name, arguments)
}
}