net.nemerosa.ontrack.model.labels.Label.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-model Show documentation
Show all versions of ontrack-model Show documentation
Ontrack module: ontrack-model
package net.nemerosa.ontrack.model.labels
import net.nemerosa.ontrack.common.toRGBColor
open class Label(
val id: Int,
val category: String?,
val name: String,
val description: String?,
val color: String,
val computedBy: LabelProviderDescription?
) {
/**
* Foreground colour
*/
val foregroundColor: String get() = color.toRGBColor().toBlackOrWhite().toString()
/**
* Representation
*/
fun getDisplay() = if (category != null) {
"$category:$name"
} else {
name
}
companion object {
fun categoryAndNameFromDisplay(display: String): Pair {
val index = display.indexOf(':')
return if (index >= 0) {
val category = display.substring(0, index).trim().takeIf { it.isNotBlank() }
val name = display.substring(index + 1).trim()
category to name
} else {
null to display
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy