/// /// Variant_Boolean_String_Double.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// package com.margelo.nitro.acousticconnectrn import com.facebook.proguard.annotations.DoNotStrip /** * Represents the TypeScript variant "Boolean | String | Double". */ @Suppress("ClassName") @DoNotStrip sealed class Variant_Boolean_String_Double { @DoNotStrip data class First(@DoNotStrip val value: Boolean): Variant_Boolean_String_Double() @DoNotStrip data class Second(@DoNotStrip val value: String): Variant_Boolean_String_Double() @DoNotStrip data class Third(@DoNotStrip val value: Double): Variant_Boolean_String_Double() inline fun asType(): T? { return when (this) { is First -> (value) as? T is Second -> (value) as? T is Third -> (value) as? T } } inline fun isType(): Boolean { return asType() != null } inline fun match(first: (Boolean) -> R, second: (String) -> R, third: (Double) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) is Third -> third(value) } } val isFirst: Boolean get() = this is First val isSecond: Boolean get() = this is Second val isThird: Boolean get() = this is Third fun asFirstOrNull(): Boolean? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): String? { val value = (this as? Second)?.value ?: return null return value } fun asThirdOrNull(): Double? { val value = (this as? Third)?.value ?: return null return value } companion object { @JvmStatic @DoNotStrip fun create(value: Boolean): Variant_Boolean_String_Double = First(value) @JvmStatic @DoNotStrip fun create(value: String): Variant_Boolean_String_Double = Second(value) @JvmStatic @DoNotStrip fun create(value: Double): Variant_Boolean_String_Double = Third(value) } }