Property

abstract class Property<T> : BaseObservable<T> , GetSetter<T> (source)

A property is a variable which is modifiable and can have those mutations observed. When serializing a property to Json you can use PropertyTypeAdapterFactory to automatically serialize the stored value in place, instead of wrapping the value in a dictionary.

Whenever a config option calls for a field with type T, then a Property<T> will also work.

Parameters

<T>

the type of value this Property can hold.

Functions

Link copied to clipboard
open fun accept(t: T)
Bridge method for Consumer.
abstract fun accept(p: T)
Link copied to clipboard
open fun addObserver(observer: Observer<T>)
Add a new observer which is interested in updates about this value
Link copied to clipboard
open fun andThen(after: Consumer<in T>): Consumer<T>
Link copied to clipboard
open fun <T> constant(t: T): GetSetter<T>
Create a constant GetSetter.
Link copied to clipboard
open fun <T> floating(t: T): GetSetter<T>
Create a floating GetSetter.
Link copied to clipboard
abstract fun get(): T
Get the value.
abstract fun get(): T
Link copied to clipboard
open fun <V> map(mapper: (T) -> V): Observable<V>
Create a new Observable which will always have the value of mapper.apply(get()) and reports on updates accordingly.
Link copied to clipboard
open fun notifyObservers()
Explicitly notify observers about state changes that are internal to the stored value.
Link copied to clipboard
open fun <T> of(value: T): Property<T>
Create a Property with a given initial value.
Link copied to clipboard
open fun ofField(@Nullable owner: @Nullable Any, @NotNull field: @NotNull Field): GetSetter<out Any>
Create a GetSetter backed by a field… This GetSetter will update to and poll from the underlying field without any buffer.
Link copied to clipboard
abstract fun set(newValue: T)
Set the value.
Link copied to clipboard
open fun <T> upgrade(getSetter: GetSetter<T>): Property<T>
Upgrades a GetSetter so that access through the returned Property will notify observers, with state still managed in the old GetSetter.
Link copied to clipboard
open fun whenChanged(observer: Observer<T>)
Alias for addObserver.
Link copied to clipboard
open fun <T> wrap(getSetter: GetSetter<T>): Property<T>
Upgrades a GetSetter so that access through the returned Property will notify observers, with state still managed in the old GetSetter.