All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.sunnychung.lib.multiplatform.kotlite.model.ComparableRuntimeValue.kt Maven / Gradle / Ivy

Go to download

A Kotlin Multiplatform library to interpret Kotlite code, which is a subset of Kotlin language, in runtime in a safe way.

The newest version!
package com.sunnychung.lib.multiplatform.kotlite.model

import com.sunnychung.lib.multiplatform.kotlite.extension.fullClassName

sealed interface ComparableRuntimeValue : RuntimeValue, Comparable>

sealed interface ComparableRuntimeValueHolder : ComparableRuntimeValue, KotlinValueHolder {
    override val value: T

    override fun compareTo(other: ComparableRuntimeValue): Int {
        if (other !is ComparableRuntimeValueHolder) {
            throw RuntimeException("Compare target is not a ComparableRuntimeValueHolder but ${other::class.fullClassName}")
        }
        return (value as Comparable).compareTo(other.value as C)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy