/// /// Variant_String_Double.kt /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © 2025 Marc Rousavy @ Margelo /// package com.margelo.nitro.gradient import com.facebook.proguard.annotations.DoNotStrip /** * Represents the TypeScript variant "String | Double". */ @Suppress("ClassName") @DoNotStrip sealed class Variant_String_Double { @DoNotStrip data class First(@DoNotStrip val value: String): Variant_String_Double() @DoNotStrip data class Second(@DoNotStrip val value: Double): Variant_String_Double() @Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR) inline fun getAs(): T? = when (this) { is First -> value as? T is Second -> value as? T } val isFirst: Boolean get() = this is First val isSecond: Boolean get() = this is Second fun asFirstOrNull(): String? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): Double? { val value = (this as? Second)?.value ?: return null return value } inline fun match(first: (String) -> R, second: (Double) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) } } companion object { @JvmStatic @DoNotStrip fun create(value: String): Variant_String_Double = First(value) @JvmStatic @DoNotStrip fun create(value: Double): Variant_String_Double = Second(value) } }