/// /// Constraint.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 import com.facebook.proguard.annotations.DoNotStrip /** * Represents the TypeScript variant "FPSConstraint | VideoStabilizationModeConstraint | PreviewStabilizationModeConstraint | ResolutionBiasConstraint | VideoDynamicRangeConstraint | PhotoHDRConstraint | PixelFormatConstraint | BinnedConstraint". */ @Suppress("ClassName") @DoNotStrip sealed class Constraint { @DoNotStrip data class First(@DoNotStrip val value: FPSConstraint): Constraint() @DoNotStrip data class Second(@DoNotStrip val value: VideoStabilizationModeConstraint): Constraint() @DoNotStrip data class Third(@DoNotStrip val value: PreviewStabilizationModeConstraint): Constraint() @DoNotStrip data class Fourth(@DoNotStrip val value: ResolutionBiasConstraint): Constraint() @DoNotStrip data class Fifth(@DoNotStrip val value: VideoDynamicRangeConstraint): Constraint() @DoNotStrip data class Sixth(@DoNotStrip val value: PhotoHDRConstraint): Constraint() @DoNotStrip data class Seventh(@DoNotStrip val value: PixelFormatConstraint): Constraint() @DoNotStrip data class Eigth(@DoNotStrip val value: BinnedConstraint): Constraint() inline fun asType(): T? { return when (this) { is First -> (value) as? T is Second -> (value) as? T is Third -> (value) as? T is Fourth -> (value) as? T is Fifth -> (value) as? T is Sixth -> (value) as? T is Seventh -> (value) as? T is Eigth -> (value) as? T } } inline fun isType(): Boolean { return asType() != null } inline fun match(first: (FPSConstraint) -> R, second: (VideoStabilizationModeConstraint) -> R, third: (PreviewStabilizationModeConstraint) -> R, fourth: (ResolutionBiasConstraint) -> R, fifth: (VideoDynamicRangeConstraint) -> R, sixth: (PhotoHDRConstraint) -> R, seventh: (PixelFormatConstraint) -> R, eigth: (BinnedConstraint) -> R): R { return when (this) { is First -> first(value) is Second -> second(value) is Third -> third(value) is Fourth -> fourth(value) is Fifth -> fifth(value) is Sixth -> sixth(value) is Seventh -> seventh(value) is Eigth -> eigth(value) } } 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 val isFifth: Boolean get() = this is Fifth val isSixth: Boolean get() = this is Sixth val isSeventh: Boolean get() = this is Seventh val isEigth: Boolean get() = this is Eigth fun asFirstOrNull(): FPSConstraint? { val value = (this as? First)?.value ?: return null return value } fun asSecondOrNull(): VideoStabilizationModeConstraint? { val value = (this as? Second)?.value ?: return null return value } fun asThirdOrNull(): PreviewStabilizationModeConstraint? { val value = (this as? Third)?.value ?: return null return value } fun asFourthOrNull(): ResolutionBiasConstraint? { val value = (this as? Fourth)?.value ?: return null return value } fun asFifthOrNull(): VideoDynamicRangeConstraint? { val value = (this as? Fifth)?.value ?: return null return value } fun asSixthOrNull(): PhotoHDRConstraint? { val value = (this as? Sixth)?.value ?: return null return value } fun asSeventhOrNull(): PixelFormatConstraint? { val value = (this as? Seventh)?.value ?: return null return value } fun asEigthOrNull(): BinnedConstraint? { val value = (this as? Eigth)?.value ?: return null return value } companion object { @JvmStatic @DoNotStrip fun create(value: FPSConstraint): Constraint = First(value) @JvmStatic @DoNotStrip fun create(value: VideoStabilizationModeConstraint): Constraint = Second(value) @JvmStatic @DoNotStrip fun create(value: PreviewStabilizationModeConstraint): Constraint = Third(value) @JvmStatic @DoNotStrip fun create(value: ResolutionBiasConstraint): Constraint = Fourth(value) @JvmStatic @DoNotStrip fun create(value: VideoDynamicRangeConstraint): Constraint = Fifth(value) @JvmStatic @DoNotStrip fun create(value: PhotoHDRConstraint): Constraint = Sixth(value) @JvmStatic @DoNotStrip fun create(value: PixelFormatConstraint): Constraint = Seventh(value) @JvmStatic @DoNotStrip fun create(value: BinnedConstraint): Constraint = Eigth(value) } }