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

com.avito.android.diff.counter.OwnersDiffCounterImpl.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.counter

import com.avito.android.diff.comparator.OwnersComparator
import com.avito.android.diff.model.OwnersDiff
import com.avito.android.model.Owner

internal class OwnersDiffCounterImpl(
    private val comparator: OwnersComparator
) : OwnersDiffCounter {

    override fun countOwnersDiff(expectedOwners: Set, actualOwners: Set): OwnersDiff {
        val removed = mutableSetOf()
        val added = mutableSetOf()
        expectedOwners.forEach { expected ->
            if (actualOwners.none { actual -> comparator.isSame(expected, actual) }) {
                removed.add(expected)
            }
        }
        actualOwners.forEach { actual ->
            if (expectedOwners.none { expected -> comparator.isSame(expected, actual) }) {
                added.add(actual)
            }
        }
        return OwnersDiff(removed, added)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy