Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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