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

model.CompositeSourceSetID.kt Maven / Gradle / Ivy

Go to download

Dokka is an API documentation engine for Kotlin and Java, performing the same function as Javadoc for Java

There is a newer version: 2.0.0
Show newest version
package org.jetbrains.dokka.model

import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaSourceSetID

data class CompositeSourceSetID(
    private val children: Set
) {
    constructor(sourceSetIDs: Iterable) : this(sourceSetIDs.toSet())
    constructor(sourceSetId: DokkaSourceSetID) : this(setOf(sourceSetId))

    init {
        require(children.isNotEmpty()) { "Expected at least one source set id" }
    }

    val merged: DokkaSourceSetID
        get() = children.sortedBy { it.scopeId + it.sourceSetName }.let { sortedChildren ->
            DokkaSourceSetID(
                scopeId = sortedChildren.joinToString(separator = "+") { it.scopeId },
                sourceSetName = sortedChildren.joinToString(separator = "+") { it.sourceSetName }
            )
        }

    val all: Set
        get() = setOf(merged, *children.toTypedArray())

    operator fun contains(sourceSetId: DokkaSourceSetID): Boolean {
        return sourceSetId in all
    }

    operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean {
        return sourceSet.sourceSetID in this
    }

    operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID {
        return copy(children = children + other)
    }
}

operator fun DokkaSourceSetID.plus(other: DokkaSourceSetID): CompositeSourceSetID {
    return CompositeSourceSetID(listOf(this, other))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy