castValue

open fun castValue(value: String, requiredType: Type, valueType: String): String(source)

Cast the value if the current type doesn't match the required type. Given the following example: int withoutCast = 1; double withCast = (double) 1; The variable withoutCast doesn't need to be casted, since we have int as required type and int as value type. While in the variable withCast we have double as required type and int as value type.

Return

The value casted if needed.

Parameters

value

The value to be returned.

requiredType

The expected type to be casted if needed.

valueType

The type of the value to be returned.