/// /// InputImage.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.camera.facedetector import com.facebook.proguard.annotations.DoNotStrip /** * Represents the TypeScript variant "String | Double | ImageUri". */ @Suppress("ClassName") @DoNotStrip sealed class InputImage { @DoNotStrip data class First(@DoNotStrip val value: String): InputImage() @DoNotStrip data class Second(@DoNotStrip val value: Double): InputImage() @DoNotStrip data class Third(@DoNotStrip val value: ImageUri): InputImage() 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: (String) -> R, second: (Double) -> R, third: (ImageUri) -> 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(): String? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): Double? { val value = (this as? Second)?.value ?: return null return value } fun asThirdOrNull(): ImageUri? { val value = (this as? Third)?.value ?: return null return value } companion object { @JvmStatic @DoNotStrip fun create(value: String): InputImage = First(value) @JvmStatic @DoNotStrip fun create(value: Double): InputImage = Second(value) @JvmStatic @DoNotStrip fun create(value: ImageUri): InputImage = Third(value) } }