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

commonMain.it.unibo.tuprolog.collections.RetrieveResult.kt Maven / Gradle / Ivy

Go to download

In-memory storage and indexing facilities for ordered and unordered knowledge bases composed by logic clauses

There is a newer version: 1.0.4
Show newest version
package it.unibo.tuprolog.collections

import it.unibo.tuprolog.core.Clause
import kotlin.js.JsName

sealed class RetrieveResult {
    open val isSuccess: Boolean
        get() = false

    open val isFailure: Boolean
        get() = false

    @JsName("collection")
    abstract val collection: C

    @JsName("clauses")
    abstract val clauses: List?

    @JsName("firstClause")
    abstract val firstClause: Clause?

    data class Success(
        override val collection: C,
        override val clauses: List,
    ) : RetrieveResult() {
        override val isSuccess: Boolean
            get() = true

        override val firstClause: Clause
            get() = clauses.first()
    }

    data class Failure(override val collection: C) : RetrieveResult() {
        override val isFailure: Boolean
            get() = true

        override val clauses: Nothing?
            get() = null

        override val firstClause: Nothing?
            get() = null
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy