BaseTransaction
Keywords: net.corda.core.transactions.BaseTransaction class
Date: 2023-09-18

net.corda.core.transactions

## Class BaseTransaction

- net.corda.core.transactions.BaseTransaction

- All Implemented Interfaces:
    NamedByHash
  Direct Known Subclasses:
    CoreTransaction, FullTransaction

      @DoNotImplement
      public class BaseTransaction
      implements NamedByHash

  An abstract class defining fields shared by all transaction types in the system.

- - ### Constructor Detail

    - #### BaseTransaction

          public BaseTransaction()

      An abstract class defining fields shared by all transaction types in the system.

  - ### Method Detail

    - #### getReferences

          @NotNull
          public java.util.List<?> getReferences()

      A list of reusable reference data states which can be referred to by other contracts in this transaction.

    - #### getInputs

          @NotNull
          public java.util.List<?> getInputs()

      The inputs of this transaction. Note that in BaseTransaction subclasses the type of this list may change!

    - #### getOutputs

          @NotNull
          public java.util.List<net.corda.core.contracts.TransactionState> getOutputs()

      Ordered list of states defined by this transaction, along with the associated notaries.

    - #### getNotary

          @Nullable
          public Party getNotary()

      If present, the notary for this transaction. If absent then the transaction is not notarised at all. This is intended for issuance/genesis transactions that don't consume any other states and thus can't double spend anything.

    - #### checkBaseInvariants

          protected void checkBaseInvariants()

    - #### outRef

          @NotNull
          public <T extends ContractState> StateAndRef<T> outRef(int index)

      Returns a `class StateAndRef` for the given output index.

      See Also:
        `class StateAndRef`

    - #### outRef

          @NotNull
          public <T extends ContractState> StateAndRef<T> outRef(@NotNull
                                                                          ContractState state)

      Returns a `class StateAndRef` for the requested output state, or throws IllegalArgumentException if not found.

      See Also:
        `class StateAndRef`, IllegalArgumentException

    - #### getOutputStates

          @NotNull
          public java.util.List<net.corda.core.contracts.ContractState> getOutputStates()

      Helper property to return a list of `interface ContractState` objects, rather than the often less convenient `class TransactionState`

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

    - #### getOutput

          @NotNull
          public ContractState getOutput(int index)

      Helper to simplify getting an indexed output.

      Parameters:
        `index` - the position of the item in the output.
      Returns:
        The ContractState at the requested index

    - #### outputsOfType

          @NotNull
          public <T extends ContractState> java.util.List<T> outputsOfType(@NotNull
                                                                                    java.lang.Class<T> clazz)

      Helper to simplify getting all output states of a particular class, interface, or base class.

      Parameters:
        `clazz` - The class type used for filtering via an Class.isInstance check.Clazz must be an extension of `interface ContractState`.
      Returns:
        the possibly empty list of output states matching the clazz restriction.

    - #### filterOutputs

          @NotNull
          public <T extends ContractState> java.util.List<T> filterOutputs(@NotNull
                                                                                    java.lang.Class<T> clazz,
                                                                                    @NotNull
                                                                                    java.util.function.Predicate<T> predicate)

      Helper to simplify filtering outputs according to a Predicate.

      Parameters:
        `clazz` - The class type used for filtering via an Class.isInstance check.Clazz must be an extension of `interface ContractState`.
        `predicate` - A filtering function taking a state of type T and returning true if it should be included in the list.The class filtering is applied before the predicate.
      Returns:
        the possibly empty list of output states matching the predicate and clazz restrictions.
      See Also:
        Predicate

    - #### findOutput

          @NotNull
          public <T extends ContractState> T findOutput(@NotNull
                                                                 java.lang.Class<T> clazz,
                                                                 @NotNull
                                                                 java.util.function.Predicate<T> predicate)

      Helper to simplify finding a single output matching a Predicate.

      Parameters:
        `clazz` - The class type used for filtering via an Class.isInstance check.Clazz must be an extension of `interface ContractState`.
        `predicate` - A filtering function taking a state of type T and returning true if this is the desired item.The class filtering is applied before the predicate.
      Returns:
        the single item matching the predicate.
      Throws:
        `IllegalArgumentException` - if no item, or multiple items are found matching the requirements.
      See Also:
        Predicate

    - #### outRefsOfType

          @NotNull
          public <T extends ContractState> java.util.List<net.corda.core.contracts.StateAndRef> outRefsOfType(@NotNull
                                                                                                                       java.lang.Class<T> clazz)

      Helper to simplify getting all output `class StateAndRef` items of a particular state class, interface, or base class.

      Parameters:
        `clazz` - The class type used for filtering via an Class.isInstance check.Clazz must be an extension of `interface ContractState`.
      Returns:
        the possibly empty list of output `class StateAndRef` states matching the clazz restriction.
      See Also:
        `class StateAndRef`

    - #### filterOutRefs

          @NotNull
          public <T extends ContractState> java.util.List<net.corda.core.contracts.StateAndRef> filterOutRefs(@NotNull
                                                                                                                       java.lang.Class<T> clazz,
                                                                                                                       @NotNull
                                                                                                                       java.util.function.Predicate<T> predicate)

      Helper to simplify filtering output `class StateAndRef` items according to a Predicate.

      Parameters:
        `clazz` - The class type used for filtering via an Class.isInstance check.Clazz must be an extension of `interface ContractState`.
        `predicate` - A filtering function taking a state of type T and returning true if it should be included in the list.The class filtering is applied before the predicate.
      Returns:
        the possibly empty list of output `class StateAndRef` states matching the predicate and clazz restrictions.
      See Also:
        `class StateAndRef`, Predicate

    - #### findOutRef

          @NotNull
          public <T extends ContractState> StateAndRef<T> findOutRef(@NotNull
                                                                              java.lang.Class<T> clazz,
                                                                              @NotNull
                                                                              java.util.function.Predicate<T> predicate)

      Helper to simplify finding a single output `class StateAndRef` matching a Predicate.

      Parameters:
        `clazz` - The class type used for filtering via an Class.isInstance check.Clazz must be an extension of `interface ContractState`.
        `predicate` - A filtering function taking a state of type T and returning true if this is the desired item.The class filtering is applied before the predicate.
      Returns:
        the single `class StateAndRef` item matching the predicate.
      Throws:
        `IllegalArgumentException` - if no item, or multiple items are found matching the requirements.
      See Also:
        `class StateAndRef`, Predicate

    - #### toString

          @NotNull
          public java.lang.String toString()