com.netflix.java.refactor.fix.PackageComparator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-source-refactor Show documentation
Show all versions of java-source-refactor Show documentation
Pluggable and distributed refactoring tool for Java source code
package com.netflix.java.refactor.fix
import java.util.*
class PackageComparator: Comparator {
override fun compare(p1: String, p2: String): Int {
val p1s = p1.split(".")
val p2s = p2.split(".")
p1s.forEachIndexed { i, fragment ->
if(p2s.size < i + 1) return@compare 1
if(fragment != p2s[i]) return@compare fragment.compareTo(p2s[i])
}
return if(p1s.size < p2s.size) -1 else 0
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy