com.gojek.courier.extensions.CollectionExtensions.kt Maven / Gradle / Ivy
package com.gojek.courier.extensions
private class ImmutableMap(private val inner: Map) : Map by inner {
override fun equals(other: Any?): Boolean {
return inner == other
}
override fun hashCode(): Int {
return inner.hashCode()
}
override fun toString(): String {
return inner.toString()
}
}
fun Map.toImmutableMap(): Map {
return if (this is ImmutableMap) {
this
} else {
ImmutableMap(this)
}
}
private class ImmutableSet(private val inner: Set) : Set by inner {
override fun equals(other: Any?): Boolean {
return inner == other
}
override fun hashCode(): Int {
return inner.hashCode()
}
override fun toString(): String {
return inner.toString()
}
}
fun Set.toImmutableSet(): Set {
return if (this is ImmutableSet) {
this
} else {
ImmutableSet(this)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy