1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Clean up.

This commit is contained in:
Cedric Beust 2016-02-17 02:23:00 +04:00
parent 2a236605a0
commit 9097bf2fd6

View file

@ -85,30 +85,20 @@ class Version(val version: String, val snapshotTimestamp: String? = null): Compa
} }
} }
override fun compareTo(other: Version): Int { override fun compareTo(other: Version) = comparator.compare(this, other)
return comparator.compare(this, other)
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?) = (other is Version) && comparator.compare(this, other) == 0
return (other is Version) && comparator.compare(this, other) == 0
}
override fun hashCode(): Int { override fun hashCode(): Int {
if ( hash == -1 ) hash = Arrays.hashCode(items.toTypedArray()) if ( hash == -1 ) hash = Arrays.hashCode(items.toTypedArray())
return hash return hash
} }
override fun toString(): String { override fun toString() = version
return version
}
fun isSnapshot(): Boolean { fun isSnapshot() = items.firstOrNull { it.isSnapshot } != null
return items.firstOrNull { it.isSnapshot } != null
}
fun isRangedVersion(): Boolean { fun isRangedVersion() = MavenId.isRangedVersion(version)
return MavenId.isRangedVersion(version)
}
fun select(list: List<Version>): Version? { fun select(list: List<Version>): Version? {
if (!(version.first() in listOf('[', '(') && version.last() in listOf(']', ')'))) { if (!(version.first() in listOf('[', '(') && version.last() in listOf(']', ')'))) {