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

com.gojek.courier.extensions.CollectionExtensions.kt Maven / Gradle / Ivy

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