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

maestro.orchestra.yaml.YamlInputText.kt Maven / Gradle / Ivy

Go to download

Maestro is a server-driven platform-agnostic library that allows to drive tests for both iOS and Android using the same implementation through an intuitive API.

There is a newer version: 1.39.2
Show newest version
package maestro.orchestra.yaml

import com.fasterxml.jackson.annotation.JsonCreator
import java.lang.UnsupportedOperationException

data class YamlInputText(
    val text: String,
    val label: String? = null,
) {

    companion object {

        @JvmStatic
        @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
        fun parse(text: Any): YamlInputText {
            val inputText = when (text) {
                is String -> text
                is Map<*, *> -> {
                    val input = text.getOrDefault("text", "") as String
                    val label = text.getOrDefault("label", "") as String
                    return YamlInputText(input, label)
                }
                is Int, is Long, is Char, is Boolean, is Float, is Double -> text.toString()
                else -> throw UnsupportedOperationException("Cannot deserialize input text with data type ${text.javaClass}")
            }
            return YamlInputText(text = inputText)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy