net.corda.contracts.asset

## Class Obligation.State<P>

- net.corda.contracts.asset.Obligation.State<P>

- Type Parameters:
    `P` - the product the obligation is for payment of.
  All Implemented Interfaces:
    BilateralNettableState<N>, ContractState, FungibleAsset<T>, MultilateralNettableState<T>, NettableState<N,T>, OwnableState
  Enclosing class:
    Obligation<P>

      public static class Obligation.State<P>
      implements FungibleAsset<T>, NettableState<N,T>

  A state representing the obligation of one party (obligor) to deliver a specified number of units of an underlying asset (described as token.acceptableIssuedProducts) to the beneficiary no later than the specified time.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `State(Obligation.Lifecycle lifecycle, AnonymousParty obligor, Obligation.Terms<P> template, long quantity, CompositeKey beneficiary)` A state representing the obligation of one party (obligor) to deliver a specified number of units of an underlying asset (described as token.acceptableIssuedProducts) to the beneficiary no later than the specified time.
    `State(Obligation.Lifecycle lifecycle, Party obligor, Obligation.Terms<P> template, long quantity, CompositeKey beneficiary)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Obligation.Lifecycle` | `component1()`
    `AnonymousParty` | `component2()` Where the debt originates from
    `Obligation.Terms<P>` | `component3()`
    `long` | `component4()`
    `CompositeKey` | `component5()` The public key of the entity the contract pays to
    `Obligation.State<P>` | `copy(Obligation.Lifecycle lifecycle, AnonymousParty obligor, Obligation.Terms<P> template, long quantity, CompositeKey beneficiary)` A state representing the obligation of one party (obligor) to deliver a specified number of units of an underlying asset (described as token.acceptableIssuedProducts) to the beneficiary no later than the specified time.
    `boolean` | `equals(java.lang.Object p)`
    `Amount<net.corda.core.contracts.Issued>` | `getAmount()`
    `CompositeKey` | `getBeneficiary()` The public key of the entity the contract pays to
    `BilateralNetState<P>` | `getBilateralNetState()` Returns an object used to determine if two states can be subject to close-out netting. If two states return equal objects, they can be close out netted together.
    `Obligation<java.util.Currency>` | `getContract()` An instance of the contract class that will verify this state.
    `java.time.Instant` | `getDueBefore()`
    `java.util.Collection<net.corda.core.crypto.CompositeKey>` | `getExitKeys()` There must be an ExitCommand signed by these keys to destroy the amount. While all states require their owner to sign, some (i.e. cash) also require the issuer.
    `Obligation.Lifecycle` | `getLifecycle()`
    `MultilateralNetState<P>` | `getMultilateralNetState()` Returns an object used to determine if two states can be subject to close-out netting. If two states return equal objects, they can be close out netted together.
    `AnonymousParty` | `getObligor()` Where the debt originates from
    `CompositeKey` | `getOwner()` There must be a MoveCommand signed by this key to claim the amount
    `java.util.List<net.corda.core.crypto.CompositeKey>` | `getParticipants()` A participant is any party that is able to consume this state in a valid transaction.
    `long` | `getQuantity()`
    `Obligation.Terms<P>` | `getTemplate()`
    `int` | `hashCode()`
    `Obligation.State<P>` | `move(Amount<net.corda.core.contracts.Issued> newAmount, CompositeKey newOwner)`
    `Obligation.State<P>` | `net(Obligation.State<P> other)` Perform bilateral netting of this state with another state. The two states must be compatible (as in bilateralNetState objects are equal).
    `void` | `setLifecycle(Obligation.Lifecycle p)`
    `java.lang.String` | `toString()`
    `kotlin.Pair<net.corda.contracts.asset.Obligation.Commands.Move,net.corda.contracts.asset.Obligation.State>` | `withNewOwner(CompositeKey newOwner)` Copies the underlying data structure, replacing the owner field with this new value and leaving the rest alone

    - ### Methods inherited from interface net.corda.core.contracts.FungibleAsset

      `getAmount, getExitKeys, getOwner, move`

    - ### Methods inherited from interface net.corda.core.contracts.OwnableState

      `getOwner, withNewOwner`

    - ### Methods inherited from interface net.corda.core.contracts.ContractState

      `getContract, getParticipants`

    - ### Methods inherited from interface net.corda.core.contracts.BilateralNettableState

      `getBilateralNetState, net`

    - ### Methods inherited from interface net.corda.core.contracts.MultilateralNettableState

      `getMultilateralNetState`

- - ### Constructor Detail

    - #### State

          public State(Obligation.Lifecycle lifecycle,
                       AnonymousParty obligor,
                       Obligation.Terms<P> template,
                       long quantity,
                       CompositeKey beneficiary)

      A state representing the obligation of one party (obligor) to deliver a specified number of units of an underlying asset (described as token.acceptableIssuedProducts) to the beneficiary no later than the specified time.

      Parameters:
        `obligor` - Where the debt originates from(obligor)
        `beneficiary` - The public key of the entity the contract pays to

    - #### State

          public State(Obligation.Lifecycle lifecycle,
                       Party obligor,
                       Obligation.Terms<P> template,
                       long quantity,
                       CompositeKey beneficiary)

  - ### Method Detail

    - #### getAmount

          public Amount<net.corda.core.contracts.Issued> getAmount()

    - #### getContract

          public Obligation<java.util.Currency> getContract()

      An instance of the contract class that will verify this state.

      # Discussion

      This field is not the final design, it's just a piece of temporary scaffolding. Once the contract sandbox is further along, this field will become a description of which attachments are acceptable for defining the contract.

      Recall that an attachment is a zip file that can be referenced from any transaction. The contents of the attachments are merged together and cannot define any overlapping files, thus for any given transaction there is a miniature file system in which each file can be precisely mapped to the defining attachment.

      Attachments may contain many things (data files, legal documents, etc) but mostly they contain JVM bytecode. The class files inside define not only `interface Contract` implementations but also the classes that define the states. Within the rest of a transaction, user-providable components are referenced by name only.

      This means that a smart contract in Corda does two things:

      1. Define the data structures that compose the ledger (the states)

      2. Define the rules for updating those structures

      The first is merely a utility role ... in theory contract code could manually parse byte streams by hand. The second is vital to the integrity of the ledger. So this field needs to be able to express constraints like:

      - Only attachment 733c350f396a727655be1363c06635ba355036bd54a5ed6e594fd0b5d05f42f6 may be used with this state.

      - Any attachment signed by public key 2d1ce0e330c52b8055258d776c40 may be used with this state.

      - Attachments (1, 2, 3) may all be used with this state.

      and so on. In this way it becomes possible for the business logic governing a state to be evolved, if the constraints are flexible enough.

      Because contract classes often also define utilities that generate relevant transactions, and because attachments cannot know their own hashes, we will have to provide various utilities to assist with obtaining the right code constraints from within the contract code itself.

      TODO: Implement the above description. See COR-226

      See Also:
        `interface Contract`

    - #### getExitKeys

          public java.util.Collection<net.corda.core.crypto.CompositeKey> getExitKeys()

      There must be an ExitCommand signed by these keys to destroy the amount. While all states require their owner to sign, some (i.e. cash) also require the issuer.

    - #### getDueBefore

          public java.time.Instant getDueBefore()

    - #### getParticipants

          public java.util.List<net.corda.core.crypto.CompositeKey> getParticipants()

      A participant is any party that is able to consume this state in a valid transaction.

      The list of participants is required for certain types of transactions. For example, when changing the notary for this state (`class TransactionType.NotaryChange`), every participant has to be involved and approve the transaction so that they receive the updated state, and don't end up in a situation where they can no longer use a state they possess, since someone consumed that state during the notary change process.

      The participants list should normally be derived from the contents of the state. E.g. for `class Cash` the participants list should just contain the owner.

      See Also:
        `class TransactionType.NotaryChange`, `class Cash`

    - #### getOwner

          public CompositeKey getOwner()

      There must be a MoveCommand signed by this key to claim the amount

    - #### move

          public Obligation.State<P> move(Amount<net.corda.core.contracts.Issued> newAmount,
                                          CompositeKey newOwner)

    - #### toString

          public java.lang.String toString()

    - #### getBilateralNetState

          public BilateralNetState<P> getBilateralNetState()

      Returns an object used to determine if two states can be subject to close-out netting. If two states return equal objects, they can be close out netted together.

    - #### getMultilateralNetState

          public MultilateralNetState<P> getMultilateralNetState()

      Returns an object used to determine if two states can be subject to close-out netting. If two states return equal objects, they can be close out netted together.

    - #### net

          public Obligation.State<P> net(Obligation.State<P> other)

      Perform bilateral netting of this state with another state. The two states must be compatible (as in bilateralNetState objects are equal).

    - #### withNewOwner

          public kotlin.Pair<net.corda.contracts.asset.Obligation.Commands.Move,net.corda.contracts.asset.Obligation.State> withNewOwner(CompositeKey newOwner)

      Copies the underlying data structure, replacing the owner field with this new value and leaving the rest alone

    - #### getLifecycle

          public Obligation.Lifecycle getLifecycle()

    - #### setLifecycle

          public void setLifecycle(Obligation.Lifecycle p)

    - #### getObligor

          public AnonymousParty getObligor()

      Where the debt originates from

      (obligor)

    - #### getTemplate

          public Obligation.Terms<P> getTemplate()

    - #### getQuantity

          public long getQuantity()

    - #### getBeneficiary

          public CompositeKey getBeneficiary()

      The public key of the entity the contract pays to

    - #### component1

          public Obligation.Lifecycle component1()

    - #### component2

          public AnonymousParty component2()

      Where the debt originates from

      (obligor)

    - #### component3

          public Obligation.Terms<P> component3()

    - #### component4

          public long component4()

    - #### component5

          public CompositeKey component5()

      The public key of the entity the contract pays to

    - #### copy

          public Obligation.State<P> copy(Obligation.Lifecycle lifecycle,
                                          AnonymousParty obligor,
                                          Obligation.Terms<P> template,
                                          long quantity,
                                          CompositeKey beneficiary)

      A state representing the obligation of one party (obligor) to deliver a specified number of units of an underlying asset (described as token.acceptableIssuedProducts) to the beneficiary no later than the specified time.

    - #### hashCode

          public int hashCode()

    - #### equals

          public boolean equals(java.lang.Object p)