ValidatedProperty

open class ValidatedProperty<V>(initialValue: V, bean: Any? = null, beanName: String? = null, val validation: (ValidatedProperty<V>, V, V) -> V) : PropertyBase<V>

A Property whose value is validated before being set. Whenever value is changed, validation is called with the old and new values. validation returns a validated value.

validation takes 3 arguments (similar to ChangeListener :

  1. this property

  2. oldValue

  3. newValue

For example, to reject a value, keeping the old value :

val myStringProperty = ValidatedProperty("Hello") { _, old, new ->
    if (old.isBlank()) old else new
}

Inheritors

Constructors

Link copied to clipboard
constructor(initialValue: V, bean: Any? = null, beanName: String? = null, validation: (ValidatedProperty<V>, V, V) -> V)

Properties

Link copied to clipboard
open override val bean: Any?
Link copied to clipboard
open override val beanName: String?
Link copied to clipboard

The validation. Args :

Link copied to clipboard
open override var value: V

Functions

Link copied to clipboard

open override fun addBindChangeListener(listener: ChangeListener<V, ObservableValue<V>>)

Identical to addChangeListener, but these listeners are guaranteed to fire BEFORE other listeners. These should be used for the sole purpose of updating single ObservableValues which are dependent on this ObservableValue. This helps (but doesn't guarantee) that properties change atomically. i.e. when one property changes, a related property also changes before other (regular) listeners fire. Therefore, the (regular) listeners cannot read inconsistent values.

Link copied to clipboard

open override fun addBindListener(listener: InvalidationListener)

Identical to addListener, but these listeners are guaranteed to fire BEFORE regular listeners. These should be used for the sole purpose of updating other ObservableValues which are dependent on this Observable.

Link copied to clipboard
Link copied to clipboard
open override fun addListener(listener: InvalidationListener)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Converts an ObservableValue, with a non-nullable to value, to an ObservableValue whose value IS nullable.

Link copied to clipboard
Link copied to clipboard
open override fun bidirectionalBind(other: Property<V>): BidirectionalBind
open override fun <B> bidirectionalBind(other: Property<B>, converter: Converter<V, B>): BidirectionalBind

This property's value is set to other's value, and then both values are bound to each other. i.e. if either property changes, the other will also change.

Link copied to clipboard
open override fun bidirectionalUnbind(other: Property<*>?)

Removes a bidirectional bind created using bidirectionalBind.

Link copied to clipboard
open fun <T : V> bindCastTo(bindTo: ObservableValue<T>)

This is the same as bindTo, but casting this to Property<T>, suppressing the unchecked cast. I believe this is fine in all cases.

Link copied to clipboard
open override fun bindTo(to: ObservableValue<V>)

The value of this property is bound to the value of property to.

Link copied to clipboard
Link copied to clipboard
open operator fun getValue(thisRef: Any, kProperty: KProperty<*>): V

Lets us declare a val using a for the value of this property, using this as a delegate. e.g.

Link copied to clipboard
open override fun isBound(): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun removeChangeListener(listener: ChangeListener<V, ObservableValue<V>>)
Link copied to clipboard
open override fun removeListener(listener: InvalidationListener)
Link copied to clipboard

Converts an ObservableValue, with a nullable to value, to an ObservableValue whose value is NOT nullable, by supplying a defaultValue.

Link copied to clipboard
Link copied to clipboard
open operator fun setValue(thisRef: Any, kProperty: KProperty<*>, newValue: V)

Lets us declare a var for the value of this property. e.g.

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun unbind()