corda / net.corda.core.contracts / StatePointer

StatePointer

@DoNotImplement sealed class StatePointer<T : ContractState>

A StatePointer contains a pointer to a ContractState. The StatePointer can be included in a ContractState or included in an off-ledger data structure. StatePointers can be resolved to a StateAndRef by performing a vault query. There are two types of pointers; linear and static. LinearPointers are for use with LinearStates. StaticPointers are for use with any type of ContractState.

Properties

isResolved

abstract val isResolved: Boolean

Determines whether the state pointer should be resolved to a reference input when used in a transaction.

pointer

abstract val pointer: Any

An identifier for the ContractState that this StatePointer points to.

type

abstract val type: Class<T>

Type of the state which is being pointed to.

Functions

resolve

abstract fun resolve(services: ServiceHub): StateAndRef<T>

Resolves a StatePointer to a StateAndRef via a vault query. This method will either return a StateAndRef or return an exception.

abstract fun resolve(ltx: LedgerTransaction): StateAndRef<T>

Resolves a StatePointer to a StateAndRef from inside a LedgerTransaction. The intuition here is that all of the pointed-to states will be included in the transaction as reference states.

Companion Object Functions

linearPointer

fun <T : LinearState> linearPointer(state: T, isResolved: Boolean = true): <ERROR CLASS>

Creates a LinearPointer to the specified linear state.

staticPointer

fun <T : ContractState> staticPointer(stateAndRef: StateAndRef<T>, isResolved: Boolean = false): <ERROR CLASS>

Creates a StaticPointer to the specified contract state.

Extension Functions

contextLogger

fun Any.contextLogger(): <ERROR CLASS>

When called from a companion object, returns the logger for the enclosing class.

Inheritors

LinearPointer

class LinearPointer<T : LinearState> : StatePointer<T>

LinearPointer allows a ContractState to "point" to another LinearState creating a "many-to-one" relationship between all the states containing the pointer to a particular LinearState and the LinearState being pointed to. Using the LinearPointer is useful when one state depends on the data contained within another state that evolves independently. When using LinearPointer it is worth noting:

StaticPointer

class StaticPointer<T : ContractState> : StatePointer<T>

A StaticPointer contains a pointer to a specific StateRef and can be resolved by looking up the StateRef via ServiceHub. There are a number of things to keep in mind when using StaticPointers: