/// /// Variant_ArrayBuffer_String.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.nitrofetch import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.ArrayBuffer /** * Represents the TypeScript variant "ArrayBuffer | String". */ @Suppress("ClassName") @DoNotStrip sealed class Variant_ArrayBuffer_String { @DoNotStrip data class First(@DoNotStrip val value: ArrayBuffer): Variant_ArrayBuffer_String() @DoNotStrip data class Second(@DoNotStrip val value: String): Variant_ArrayBuffer_String() val isFirst: Boolean get() = this is First val isSecond: Boolean get() = this is Second fun asFirstOrNull(): ArrayBuffer? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): String? { val value = (this as? Second)?.value ?: return null return value } inline fun match(first: (ArrayBuffer) -> R, second: (String) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) } } companion object { @JvmStatic @DoNotStrip fun create(value: ArrayBuffer): Variant_ArrayBuffer_String = First(value) @JvmStatic @DoNotStrip fun create(value: String): Variant_ArrayBuffer_String = Second(value) } }