StatePointer
Keywords: net.corda.core.contracts.StatePointer class
Date: 2023-09-18

net.corda.core.contracts

## Class StatePointer<T extends ContractState>

- net.corda.core.contracts.StatePointer<T>

- Direct Known Subclasses:
    LinearPointer, StaticPointer

      @DoNotImplement
      public class StatePointer<T extends ContractState>

  A `class StatePointer` contains a `pointer` to a `interface ContractState`. The `class StatePointer` can be included in a `interface ContractState` or included in an off-ledger data structure. `class StatePointer`s can be resolved to a `class StateAndRef` by performing a vault query. There are two types of pointers; linear and static. `class LinearPointer`s are for use with `interface LinearState`s. `class StaticPointer`s are for use with any type of `interface ContractState`.

  See Also:
    `class StatePointer`, `pointer`, `interface ContractState`, `class StatePointer`, `interface ContractState`, `class StatePointer`, `class StateAndRef`, `class LinearPointer`, `interface LinearState`, `class StaticPointer`, `interface ContractState`

- - ### Field Detail

    - #### Companion

          public static net.corda.core.contracts.StatePointer.Companion Companion

  - ### Method Detail

    - #### getPointer

          @NotNull
          public java.lang.Object getPointer()

      An identifier for the `interface ContractState` that this `class StatePointer` points to.

      See Also:
        `interface ContractState`, `class StatePointer`

    - #### getType

          @NotNull
          public java.lang.Class<T> getType()

      Type of the state which is being pointed to.

    - #### isResolved

          public boolean isResolved()

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

    - #### resolve

          @NotNull
          public StateAndRef<T> resolve(@NotNull
                                                 ServiceHub services)

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

      Parameters:
        `services` - a `interface ServiceHub` implementation is required to resolve the pointer.
      See Also:
        `class StatePointer`, `class StateAndRef`, `class StateAndRef`

    - #### resolve

          @NotNull
          public StateAndRef<T> resolve(@NotNull
                                                 LedgerTransaction ltx)

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

      Parameters:
        `ltx` - the `class LedgerTransaction` containing the `pointer` and pointed-to states.
      See Also:
        `class StatePointer`, `class StateAndRef`, `class LedgerTransaction`