net.corda.core.contracts.clauses

## Class Clause<S extends ContractState,C extends CommandData,K>

- net.corda.core.contracts.clauses.Clause<S,C,K>

- Type Parameters:
    `S` - the type of contract state this clause operates on.
    `C` - a common supertype of commands this clause operates on.
    `K` - the type of the grouping key for states this clause operates on. Use Unit if not applicable.
  Direct Known Subclasses:
    AbstractConserveAmount, AbstractIssue, LinearState.ClauseVerifier, CompositeClause, FilterOn, GroupClauseVerifier, Clauses.Move, NetClause, NoZeroSizedOutputs, Clauses.Redeem, Clauses.SetLifecycle, Clauses.Settle, Clauses.VerifyLifecycle

      public class Clause<S extends ContractState,C extends CommandData,K>

  A clause of a contract, containing a chunk of verification logic. That logic may be delegated to other clauses, or provided directly by this clause.

  See Also:
    `class CompositeClause`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Clause.Companion`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Clause.Companion` | `Companion`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Clause()` A clause of a contract, containing a chunk of verification logic. That logic may be delegated to other clauses, or provided directly by this clause.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.List<net.corda.core.contracts.clauses.Clause>` | `getExecutionPath(java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends C>> commands)` Determine the subclauses which will be verified as a result of verifying this clause.
    `java.util.Set<java.lang.Class>` | `getRequiredCommands()` Determine whether this clause runs or not
    `java.util.Set<C>` | `verify(TransactionForContract tx, java.util.List<? extends S> inputs, java.util.List<? extends S> outputs, java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends C>> commands, K groupingKey)` Verify the transaction matches the conditions from this clause. For example, a "no zero amount output" clause would check each of the output states that it applies to, looking for a zero amount, and throw IllegalStateException if any matched.

- - ### Field Detail

    - #### Companion

          public static Clause.Companion Companion

  - ### Constructor Detail

    - #### Clause

          public Clause()

      A clause of a contract, containing a chunk of verification logic. That logic may be delegated to other clauses, or provided directly by this clause.

      See Also:
        `class CompositeClause`

  - ### Method Detail

    - #### getRequiredCommands

          public java.util.Set<java.lang.Class> getRequiredCommands()

      Determine whether this clause runs or not

    - #### getExecutionPath

          public java.util.List<net.corda.core.contracts.clauses.Clause> getExecutionPath(java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends C>> commands)

      Determine the subclauses which will be verified as a result of verifying this clause.

      Throws:
        - if the given commands do not result in a valid execution (for example no match with `class FirstOf`).

    - #### verify

          public java.util.Set<C> verify(TransactionForContract tx,
                                         java.util.List<? extends S> inputs,
                                         java.util.List<? extends S> outputs,
                                         java.util.List<? extends net.corda.core.contracts.AuthenticatedObject<? extends C>> commands,
                                         K groupingKey)

      Verify the transaction matches the conditions from this clause. For example, a "no zero amount output" clause would check each of the output states that it applies to, looking for a zero amount, and throw IllegalStateException if any matched.

      Parameters:
        `tx` - the full transaction being verified. This is provided for cases where clauses need to access states or commands outside of their normal scope.
        `inputs` - input states which are relevant to this clause. By default this is the set passed into verifyClause, but may be further reduced by clauses such as `class GroupClauseVerifier`.
        `outputs` - output states which are relevant to this clause. By default this is the set passed into verifyClause, but may be further reduced by clauses such as `class GroupClauseVerifier`.
        `commands` - commands which are relevant to this clause. By default this is the set passed into verifyClause, but may be further reduced by clauses such as `class GroupClauseVerifier`.
        `groupingKey` - a grouping key applied to states and commands, where applicable. Taken from `class TransactionForContract.InOutGroup`.
      Returns:
        the set of commands that are consumed IF this clause is matched, and cannot be used to match a later clause. This would normally be all commands matching "requiredCommands" for this clause, but some verify() functions may do further filtering on possible matches, and return a subset. This may also include commands that were not required (for example the Exit command for fungible assets is optional).