State

abstract class State(source)

A state holds variables that can be configured, validated, copied, and loaded.

In a State, fields are typically mutable, because the user can change the field. However, fields that themselves also contain data (e.g. a Collection or a DecoratorScheme) should be stored as immutable references (but may themselves be mutable). For example, instead of having the field var list: List<String>, a State should have the field val list: MutableList<String>. This reflects the typical case in which the user does not change the reference to the object, but changes the properties inside the object. And, more importantly, means that nested a SchemeEditor can share a single unchanging reference to a State with its nested SchemeEditors.

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The context of this state in the form of a reference to the Settings.

Link copied to clipboard
var uuid: String

A UUID to uniquely track this scheme even when it is copied.

Functions

Link copied to clipboard
open fun applyContext(context: Box<Settings>)

Sets the State.context of this State to context.

fun applyContext(context: Settings)

Sets the State.context of this State to be a reference to context.

Link copied to clipboard
abstract fun deepCopy(retainUuid: Boolean = false): State

Returns a deep copy, retaining the uuid if and only if retainUuid is true.

Link copied to clipboard
protected fun <SELF : State> SELF.deepCopyTransient(retainUuid: Boolean): SELF

When invoked by the instance this on (another) instance self as self.deepCopyTransient(), this method copies Transient fields from this to self, and returns self.

Link copied to clipboard
open fun doValidate(): String?

Validates the state, and indicates whether and why it is invalid.