blob: 3c1cf7de2358b490e2d7e627fc969d43f0412ce8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package org.jetbrains.dokka.model
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.DokkaSourceSetID
data class CompositeSourceSetID(
private val children: Set<DokkaSourceSetID>
) {
constructor(sourceSetIDs: Iterable<DokkaSourceSetID>) : this(sourceSetIDs.toSet())
constructor(sourceSetId: DokkaSourceSetID) : this(setOf(sourceSetId))
init {
require(children.isNotEmpty()) { "Expected at least one source set id" }
}
val merged = DokkaSourceSetID(
moduleName = children.map { it.moduleName }.reduce { acc, s -> "$acc+$s" },
sourceSetName = children.map { it.sourceSetName }.reduce { acc, s -> "$acc+$s" }
)
val all: Set<DokkaSourceSetID> = 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))
}
|