package com.dowstats.data.rgd

data class RgdData(
    val hash: Int,
    val name: String,
    val type: Int,
    val value: Any,
)

object RgdDataUtil{

    fun List<RgdData>.getRgdTableByName(name: String): List<RgdData>? {
        return this.find { it.name ==  name }?.value as List<RgdData>?
    }

    fun List<RgdData>.getBooleanByName(name: String): Boolean? {
        return this.find { it.name ==  name }?.value as Boolean?
    }

    fun List<RgdData>.getDoubleByName(name: String): Double? {
        return this.find { it.name ==  name }?.value as Double?
    }

    fun List<RgdData>.getIntByName(name: String): Int? {
        return (this.find { it.name ==  name }?.value as Double?)?.toInt()
    }

    fun List<RgdData>.getPureIntByName(name: String): Int? {
        return (this.find { it.name ==  name }?.value as Int?)
    }

    fun List<RgdData>.getStringByName(name: String): String? {
        return this.find { it.name ==  name }?.value as String?
    }
}
