/// /// RequestPurchaseResult.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.iap import com.facebook.proguard.annotations.DoNotStrip import com.margelo.nitro.core.NullType /** * Represents the TypeScript variant "NullType | PurchaseAndroid | PurchaseIOS | Array". */ @Suppress("ClassName") @DoNotStrip sealed class RequestPurchaseResult { @DoNotStrip data class First(@DoNotStrip val value: NullType): RequestPurchaseResult() @DoNotStrip data class Second(@DoNotStrip val value: PurchaseAndroid): RequestPurchaseResult() @DoNotStrip data class Third(@DoNotStrip val value: PurchaseIOS): RequestPurchaseResult() @DoNotStrip data class Fourth(@DoNotStrip val value: Array): RequestPurchaseResult() val isFirst: Boolean get() = this is First val isSecond: Boolean get() = this is Second val isThird: Boolean get() = this is Third val isFourth: Boolean get() = this is Fourth fun asFirstOrNull(): NullType? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): PurchaseAndroid? { val value = (this as? Second)?.value ?: return null return value } fun asThirdOrNull(): PurchaseIOS? { val value = (this as? Third)?.value ?: return null return value } fun asFourthOrNull(): Array? { val value = (this as? Fourth)?.value ?: return null return value } inline fun match(first: (NullType) -> R, second: (PurchaseAndroid) -> R, third: (PurchaseIOS) -> R, fourth: (Array) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) is Third -> third(value) is Fourth -> fourth(value) } } companion object { @JvmStatic @DoNotStrip fun create(value: NullType): RequestPurchaseResult = First(value) @JvmStatic @DoNotStrip fun create(value: PurchaseAndroid): RequestPurchaseResult = Second(value) @JvmStatic @DoNotStrip fun create(value: PurchaseIOS): RequestPurchaseResult = Third(value) @JvmStatic @DoNotStrip fun create(value: Array): RequestPurchaseResult = Fourth(value) } }