net.corda.core.contracts

## Interface UpgradedContract<OldState extends ContractState,NewState extends ContractState>

- Type Parameters:
    `OldState` - the old contract state (can be `interface ContractState` or other common supertype if this supports upgrading more than one state).
    `NewState` - the upgraded contract state.
  All Superinterfaces:
    Contract
  All Known Implementing Classes:
    DummyContractV2

      public UpgradedContract<OldState extends ContractState,NewState extends ContractState>
      extends Contract

  Interface which can upgrade state objects issued by a contract to a new state object issued by a different contract.

- - ### Method Summary

    All Methods Instance Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Class<? extends net.corda.core.contracts.Contract>` | `getLegacyContract()`
    `NewState` | `upgrade(OldState state)` Upgrade contract's state object to a new state object.

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

      `getLegalContractReference, verify`

- - ### Method Detail

    - #### getLegacyContract

          java.lang.Class<? extends net.corda.core.contracts.Contract> getLegacyContract()

    - #### upgrade

          NewState upgrade(OldState state)

      Upgrade contract's state object to a new state object.

      Throws:
        - if the given state object is not one that can be upgraded. This can be either that the class is incompatible, or that the data inside the state object cannot be upgraded for some reason.