Property for the one side of a relation Depending on the type of property may be an optional property

Parameters

Constructors

Link copied to clipboard
constructor(parent: Node, property: KProperty1<*, *>)

Types

Link copied to clipboard
inner class NodeProperty

Node property representing the one side of a Node relation value can be used to get/set the node

Properties

Link copied to clipboard
private var currentNode: T?

The current value of this property, may or may not be persisted to the database

Link copied to clipboard
private var isLoaded: Boolean

If true, the value of this property is already loaded (either from the database or from another value)

Link copied to clipboard

Delegate for lazy-loading the property

Link copied to clipboard
protected var nodeCache: NodeCache?

NodeCache used to load this property might be set after initial loading, but must not be changed

Link copied to clipboard
Link copied to clipboard
protected val parent: Node
Link copied to clipboard
private var persistedNode: T?

The related node as in the database null if not loaded or no relation present in the database

Link copied to clipboard
protected val property: KProperty1<*, *>
Link copied to clipboard
protected val propertyName: String

Dynamic type of parent and name of property, can be used for error messages without leaking information

Link copied to clipboard
private val supportsNull: Boolean

True if the T is marked nullable

Functions

Link copied to clipboard
private suspend fun ensureLoaded(cache: NodeCache?, loader: LazyLoadingSubqueryGenerator<T>.() -> Unit?)

Ensures that this property is loaded

Link copied to clipboard
internal open suspend override fun getLoadedProperty(cache: NodeCache?, loader: LazyLoadingSubqueryGenerator<T>.() -> Unit?): NodePropertyDelegate.NodeProperty

Gets the loaded property which is returned by the lazy loading delegate

Link copied to clipboard
internal open override fun getLoadedRelatedNodes(): Collection<Node>

Gets related nodes defined by this property, but only those already loaded (therefore no lazy loading) The relationships do not have to be persisted yet

Link copied to clipboard
internal open override fun getRelatedNodesToSave(): Collection<Node>

Gets Nodes which should be persisted when this Node is persisted

Link copied to clipboard
internal open override fun getRelationshipDiff(): RelationshipDiff

Gets the diff of added and removed relationships to persist in the database

Link copied to clipboard

Gets the lazy loading delegate which is used to get the value of the property

Link copied to clipboard
open override fun registerQueryResult(fieldDefinition: FieldDefinition, queryResult: NodeQueryResult<T & Any>)

Called to register a database query result Adds the result to the cache Can be overridden to add custom behavior (super should be called in this case)

Link copied to clipboard
internal fun setFromRemote(value: T)

Sets the node from the remote side Used to prevent unnecessary lazy loaded queries

Link copied to clipboard
open override fun validate(savingNodes: Set<Node>, relationshipDefinition: RelationshipDefinition, nodeDefinitionCollection: NodeDefinitionCollection)

Called to validate the property Should throw an exception if the property is invalid, with an appropriate reason