Implement more interfaces
This commit is contained in:
parent
ae1514700b
commit
058fe57a61
@ -12,6 +12,7 @@ import java.io.InputStream
|
||||
import java.lang.ref.WeakReference
|
||||
import java.math.BigDecimal
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
import java.util.function.Supplier
|
||||
import kotlin.ConcurrentModificationException
|
||||
import kotlin.collections.ArrayList
|
||||
@ -35,7 +36,7 @@ fun interface FieldSetter<V> {
|
||||
fun invoke(value: V, field: FieldAccess<V>, setByRemote: Boolean)
|
||||
}
|
||||
|
||||
sealed interface IField<V> : ReadOnlyProperty<Any, V> {
|
||||
sealed interface IField<V> : ReadOnlyProperty<Any, V>, Supplier<V>, () -> V {
|
||||
fun observe(): Boolean
|
||||
fun markDirty()
|
||||
fun markDirty(endpoint: FieldSynchronizer.Endpoint)
|
||||
@ -47,15 +48,27 @@ sealed interface IField<V> : ReadOnlyProperty<Any, V> {
|
||||
override fun getValue(thisRef: Any, property: KProperty<*>): V {
|
||||
return value
|
||||
}
|
||||
|
||||
override fun get(): V {
|
||||
return value
|
||||
}
|
||||
|
||||
override fun invoke(): V {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface IMutableField<V> : IField<V>, ReadWriteProperty<Any, V> {
|
||||
sealed interface IMutableField<V> : IField<V>, ReadWriteProperty<Any, V>, Consumer<V> {
|
||||
override var value: V
|
||||
|
||||
override fun setValue(thisRef: Any, property: KProperty<*>, value: V) {
|
||||
this.value = value
|
||||
}
|
||||
|
||||
override fun accept(t: V) {
|
||||
value = t
|
||||
}
|
||||
|
||||
override fun getValue(thisRef: Any, property: KProperty<*>): V {
|
||||
return super.getValue(thisRef, property)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user