added a couple of helper functions to make it easier to compare values, implement Comparable and create Comparators
This commit is contained in:
@@ -95,15 +95,7 @@ class KDocConfig() {
|
||||
|
||||
protected class LongestFirstStringComparator() : Comparator<String> {
|
||||
override fun compare(s1: String?, s2: String?): Int {
|
||||
// TODO could we make this kind of code much easier?
|
||||
if (s1 == s2) return 0
|
||||
if (s1 == null) return -1
|
||||
if (s2 == null) return 1
|
||||
var answer = s1.length() - s2.length()
|
||||
if (answer == 0) {
|
||||
answer = s1.compareTo(s2)
|
||||
}
|
||||
return answer
|
||||
return compareBy(s1, s2, { (s: String) -> s.length() })
|
||||
}
|
||||
|
||||
override fun equals(obj : Any?) : Boolean {
|
||||
|
||||
Reference in New Issue
Block a user