data class Thermostat(
// ... other properties
@SerializedName("units")
private var _units: String?, // Fahrenheit,
// ... other properties
) : Serializable {
var units: String? = null
get() = _units
set(value) {
MyApplication.temperatureServerIsCelsius = (!value?.equals("Fahrenheit")!!)
_units = value
}
}
When _units receives the value, I want to assign that value to units (inside the model class) but, it isn't doing so here.
Actually, I want a variable in MyApplication modified in accordance with the value of the _units field.
How can I achieve that? Is there any way we can use get set method directly in field? like this(I know these is not correct but anything like these possible?)
data class Thermostat(
// ... other properties
@SerializedName("units")
private var _units: String?
get() = _units
set(value) {
MyApplication.temperatureServerIsCelsius =
(!value?.equals("Fahrenheit")!!)
}
)
Any solution or any other way to do this type thing?.