Interface UtxoLedgerTokenStateObserver

  • All Implemented Interfaces:

    @Deprecated(since = "5.1", forRemoval = true) 
    public interface UtxoLedgerTokenStateObserver<T extends ContractState>
    
                        

    Defines a mechanism to observe produced contract states of type T when they are committed to the ledger.

    Users should implement this interface for any states that need to be selectable via the TokenSelection API.

    The Corda platform will discover and invoke implementations of this interface for all produced states that match the type specified by getStateType.

    Example usage:

    • Java:
      
      public class ExampleStateJ implements ContractState {
      public List<PublicKey> participants;
      public SecureHash issuer;
      public String currency;
      public BigDecimal amount;
      
      
      public List<PublicKey> getParticipants() {
      return participants;
      }
      }
      
      public class UtxoLedgerTokenStateObserverJavaExample implements UtxoLedgerTokenStateObserver<ExampleStateJ> {
      
      public Class<ExampleStateJ> getStateType() {
      return ExampleStateJ.class;
      }
      
      public UtxoToken onCommit(@NotNull ExampleStateJ state) {
      return new UtxoToken(
      new UtxoTokenPoolKey(ExampleStateK.class.getName(), state.issuer, state.currency),
      state.amount,
      new UtxoTokenFilterFields()
      );
      }
      }
      
    • Kotlin:
      
      data class ExampleStateK(
      override val participants: List<PublicKey>,
      val issuer: SecureHash,
      val currency: String,
      val amount: BigDecimal
      ) : ContractState
      
      class UtxoLedgerTokenStateObserverKotlinExample : UtxoLedgerTokenStateObserver<ExampleStateK> {
      
      override val stateType = ExampleStateK::class.java
      
      override fun onCommit(state: ExampleStateK): UtxoToken {
      return UtxoToken(
      UtxoTokenPoolKey(ExampleStateK::class.java.name, state.issuer, state.currency),
      state.amount,
      UtxoTokenFilterFields()
      )
      }
      }
      
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Class<T> getStateType() Gets the ContractState type that the current observer is intended for.
      abstract UtxoToken onCommit(@NotNull() T state, @NotNull() DigestService digestService) The action to be performed when a ContractState of type T is committed to the ledger.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait