Property

public abstract class Property<T> extends BaseObservable<T> implements 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
public void accept(T t)
Bridge method for Consumer.
public abstract void accept(T p)
Link copied to clipboard
public void addObserver(Observer<T> observer)
Add a new observer which is interested in updates about this value
Link copied to clipboard
public Consumer<T> andThen(Consumer<? super T> after)
Link copied to clipboard
public static GetSetter<T> constant<T>(T t)
Create a constant GetSetter.
Link copied to clipboard
public static GetSetter<T> floating<T>(T t)
Create a floating GetSetter.
Link copied to clipboard
public abstract T get()
Get the value.
public abstract T get()
Link copied to clipboard
public Observable<V> map<V>(Function<T, V> mapper)
Create a new Observable which will always have the value of mapper.apply(get()) and reports on updates accordingly.
Link copied to clipboard
public void notifyObservers()
Explicitly notify observers about state changes that are internal to the stored value.
Link copied to clipboard
public static Property<T> of<T>(T value)
Create a Property with a given initial value.
Link copied to clipboard
public static GetSetter<? extends Object> ofField(@Nullable() Object owner, @NotNull() @NotNull() Field field)
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
public abstract void set(T newValue)
Set the value.
Link copied to clipboard
public static Property<T> upgrade<T>(GetSetter<T> getSetter)
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
public void whenChanged(Observer<T> observer)
Alias for addObserver.
Link copied to clipboard
public static Property<T> wrap<T>(GetSetter<T> getSetter)
Upgrades a GetSetter so that access through the returned Property will notify observers, with state still managed in the old GetSetter.