Companion

object Companion

Functions

Link copied to clipboard
fun convertToNonNullableType(kType: KType, value: Any): Any
Link copied to clipboard

For the purposes of this method, Double, Int, Float, Long, Short, Byte, and Boolean are all numerically convertable

Checks if the KType can be converted to a numeric value. For the purposes of this method, Boolean can be converted to number 1 = true and 0 = false

fun isNumericConvertable(kType: KType, value: Any): Boolean

Checks if the value can be converted to the KType If the types are not the same then we check if they are numbers. We assume, perhaps with some coercion that numbers can be converted to each other. There may be loss of precision during the conversion process. Also, we assume that Boolean can be converted to 1 or 0 and numbers can be converted to Boolean where value >=1 --> true, value < 1 --> false. If the underlying types are the same then this method will always return true.