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

com.avito.android.diff.comparator.AvitoModuleOwnerNameComparator.kt Maven / Gradle / Ivy

Go to download

Collection of infrastructure libraries and gradle plugins of Avito Android project

The newest version!
package com.avito.android.diff.comparator

import com.avito.android.model.AvitoCodeOwner
import com.avito.android.model.Owner
import com.avito.android.providers.RemoteAvitoCodeOwner

internal class AvitoModuleOwnerNameComparator : OwnersComparator {

    override fun isSame(expected: Owner, actual: Owner): Boolean {
        val expectedName = getOwnerIdentity(expected)
        val actualName = getOwnerIdentity(actual)
        return expectedName.equals(actualName, ignoreCase = true)
    }

    private fun getOwnerIdentity(owner: Owner): String = when (owner) {
        is AvitoCodeOwner -> owner.type.id
        is RemoteAvitoCodeOwner -> owner.id
        else -> error("Owners at avito repository must be created via AvitoCodeOwner or RemoteAvitoModuleOwner")
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy