KotlinToolingVersion: Evaluate maturity eagerly
This commit is contained in:
committed by
Space
parent
6800475202
commit
f540b4bc82
+12
-13
@@ -42,20 +42,19 @@ class KotlinToolingVersion(
|
|||||||
SNAPSHOT, DEV, MILESTONE, ALPHA, BETA, RC, STABLE
|
SNAPSHOT, DEV, MILESTONE, ALPHA, BETA, RC, STABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
val maturity: Maturity
|
val maturity: Maturity = run {
|
||||||
get() {
|
val classifier = this.classifier?.toLowerCase(Locale.ROOT)
|
||||||
val classifier = this.classifier?.toLowerCase(Locale.ROOT)
|
when {
|
||||||
return when {
|
classifier == null || classifier.matches(Regex("""(release-)?\d+""")) -> Maturity.STABLE
|
||||||
classifier == null || classifier.matches(Regex("""(release-)?\d+""")) -> Maturity.STABLE
|
classifier.matches(Regex("""(rc)(\d*)?(-release)?-?\d*""")) -> Maturity.RC
|
||||||
classifier.matches(Regex("""(rc)(\d*)?(-release)?-?\d*""")) -> Maturity.RC
|
classifier.matches(Regex("""beta(\d*)?(-release)?-?\d*""")) -> Maturity.BETA
|
||||||
classifier.matches(Regex("""beta(\d*)?(-release)?-?\d*""")) -> Maturity.BETA
|
classifier.matches(Regex("""alpha(\d*)?(-release)?-?\d*""")) -> Maturity.ALPHA
|
||||||
classifier.matches(Regex("""alpha(\d*)?(-release)?-?\d*""")) -> Maturity.ALPHA
|
classifier.matches(Regex("""m\d+(-release)?(-\d*)?""")) -> Maturity.MILESTONE
|
||||||
classifier.matches(Regex("""m\d+(-release)?(-\d*)?""")) -> Maturity.MILESTONE
|
classifier.matches(Regex("""dev-?\d*""")) -> Maturity.DEV
|
||||||
classifier.matches(Regex("""dev-?\d*""")) -> Maturity.DEV
|
classifier == "snapshot" -> Maturity.SNAPSHOT
|
||||||
classifier == "snapshot" -> Maturity.SNAPSHOT
|
else -> throw IllegalArgumentException("Can't infer maturity of KotlinVersion $this")
|
||||||
else -> throw IllegalArgumentException("Can't infer maturity of KotlinVersion $this")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun compareTo(other: KotlinToolingVersion): Int {
|
override fun compareTo(other: KotlinToolingVersion): Int {
|
||||||
if (this == other) return 0
|
if (this == other) return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user