com.avito.android.diff.counter.OwnersDiffCounterImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-ownership Show documentation
Show all versions of code-ownership Show documentation
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)
}
}