Created
March 24, 2022 12:23
-
-
Save manoj-mili/d9bd5213f1a4f63b815a0898bda92ae3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class IConfigProvider { | |
abstract fun getString(key: String): String | |
abstract fun getBoolean(key: String): Boolean | |
abstract fun getDouble(key: String): Double | |
abstract fun getLong(key: String): Long | |
abstract fun getInt(key: String): Int | |
inline fun <reified T> dataFromJson(data: String?): T? { | |
var configData: T? = null | |
try { | |
configData = Gson().fromJson( | |
data, | |
object : TypeToken<T?>() {}.type | |
) | |
} catch (e: JsonParseException) { | |
e.printStackTrace() | |
} | |
return configData | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment