diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-08-13 19:39:05 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-08-17 11:52:28 +0200 |
commit | 6f40db680336e7f3b4b68a8d4ad7b8a7ffe33270 (patch) | |
tree | 380c40023854c5a49761d2f26fded2a55c46f075 /core/src/main/kotlin/model/CompositeSourceSetID.kt | |
parent | 9fb46c158585396099b850de757f34407ad7a82b (diff) | |
download | dokka-6f40db680336e7f3b4b68a8d4ad7b8a7ffe33270.tar.gz dokka-6f40db680336e7f3b4b68a8d4ad7b8a7ffe33270.tar.bz2 dokka-6f40db680336e7f3b4b68a8d4ad7b8a7ffe33270.zip |
Moving CompositeSourceSetID and ContentSourceSet into `.dokka.model`
Diffstat (limited to 'core/src/main/kotlin/model/CompositeSourceSetID.kt')
-rw-r--r-- | core/src/main/kotlin/model/CompositeSourceSetID.kt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt new file mode 100644 index 00000000..5eb106bf --- /dev/null +++ b/core/src/main/kotlin/model/CompositeSourceSetID.kt @@ -0,0 +1,30 @@ +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 + } +} |