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

io.api.bloxy.model.dto.address.Balance.kt Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package io.api.bloxy.model.dto.address

import io.api.bloxy.model.IModel


/**
 * ! NO DESCRIPTION !
 *
 * @author GoodforGod
 * @since 17.11.2018
 */
class Balance(balances: List) : IModel {

    companion object {
        val empty: Balance = Balance(emptyList())
    }

    private val balances: Map

    init {
        this.balances = HashMap()
        balances.forEach { b -> this.balances[b.symbol] = b }
    }

    override fun isEmpty(): Boolean = balances.isEmpty()

    fun exist(symbol: String): Boolean {
        return this.balances[symbol] != null
    }

    fun getEth(): CoinBalance {
        return get("ETH") ?: CoinBalance()
    }

    fun get(symbol: String): CoinBalance? {
        return this.balances[symbol]
    }

    fun getAll(): List {
        return ArrayList(this.balances.values)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy