All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.java.refactor.fix.PackageComparator.kt Maven / Gradle / Ivy

There is a newer version: 0.6.2
Show newest version
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