You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the code has some verbose syntax for the set only properties like this:
public var disabledIconColor: Long
@Deprecated(level = DeprecationLevel.ERROR, message = "Non readable property.")
get() = nonReadable()
set(value) {
item.withDisabledIconColor(value.toInt())
}
We could replace it with syntax like this:
public var disabledIconColorProp by SetOnlyProperty<Int>({ color:Int -> item.withDisabledIconColor(color)})
Using the custom property delegate below.
The only drawback is that the code cannot use the Depreciated syntax. I think that is fine because we have an exception that will tell any programmers not to use the property.
import co.zsmb.materialdrawerkt.NonReadablePropertyException
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
class SetOnlyProperty<T>(setFunc: (T) -> Unit) : ReadWriteProperty<Any?, T> {
var setFunc: (T) -> Unit = {}
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
nonReadable();
}
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
setFunc(value)
}
fun nonReadable(): Nothing = throw NonReadablePropertyException()
}```
The text was updated successfully, but these errors were encountered:
Currently the code has some verbose syntax for the set only properties like this:
We could replace it with syntax like this:
Using the custom property delegate below.
The only drawback is that the code cannot use the Depreciated syntax. I think that is fine because we have an exception that will tell any programmers not to use the property.
The text was updated successfully, but these errors were encountered: