Add @UnderMigration annotation and options for report level
This commit is contained in:
@@ -16,21 +16,48 @@
|
||||
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
enum class Jsr305State(
|
||||
val description: String
|
||||
) {
|
||||
enum class ReportLevel(val description: String) {
|
||||
IGNORE("ignore"),
|
||||
WARN("warn"),
|
||||
STRICT("strict"),
|
||||
;
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT: Jsr305State = WARN
|
||||
|
||||
fun findByDescription(description: String?) = values().firstOrNull { it.description == description }
|
||||
fun findByDescription(description: String?): ReportLevel? = values().firstOrNull { it.description == description }
|
||||
}
|
||||
|
||||
fun isIgnored(): Boolean = this == IGNORE
|
||||
fun isWarning(): Boolean = this == WARN
|
||||
val isWarning: Boolean get() = this == ReportLevel.WARN
|
||||
val isIgnore: Boolean get() = this == ReportLevel.IGNORE
|
||||
}
|
||||
|
||||
data class Jsr305State(
|
||||
val global: ReportLevel,
|
||||
val migration: ReportLevel?,
|
||||
val user: Map<String, ReportLevel>
|
||||
) {
|
||||
val description: Array<String> by lazy {
|
||||
val result = mutableListOf<String>()
|
||||
result.add(global.description)
|
||||
|
||||
migration?.let { result.add("under-migration:${it.description}") }
|
||||
|
||||
user.forEach {
|
||||
result.add("@${it.key}:${it.value.description}")
|
||||
}
|
||||
|
||||
result.toTypedArray()
|
||||
}
|
||||
|
||||
val disabled: Boolean get() = this === DISABLED
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT: Jsr305State = Jsr305State(ReportLevel.WARN, null, emptyMap())
|
||||
|
||||
@JvmField
|
||||
val DISABLED: Jsr305State = Jsr305State(ReportLevel.IGNORE, ReportLevel.IGNORE, emptyMap())
|
||||
|
||||
@JvmField
|
||||
val STRICT: Jsr305State = Jsr305State(ReportLevel.STRICT, ReportLevel.STRICT, emptyMap())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user