net.corda.core.contracts

## Class UniqueIdentifier

- net.corda.core.contracts.UniqueIdentifier

-     public class UniqueIdentifier

  This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.

- - ### Nested Class Summary

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

  - ### Field Summary

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `UniqueIdentifier(java.lang.String externalId, java.util.UUID id)` This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.
    `UniqueIdentifier()` This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(UniqueIdentifier other)`
    `java.lang.String` | `component1()`
    `java.util.UUID` | `component2()`
    `UniqueIdentifier` | `copy(java.lang.String externalId, java.util.UUID id)` This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.
    `boolean` | `equals(java.lang.Object other)`
    `java.lang.String` | `getExternalId()`
    `java.util.UUID` | `getId()`
    `int` | `hashCode()`
    `java.lang.String` | `toString()`

- - ### Field Detail

    - #### Companion

          public static UniqueIdentifier.Companion Companion

  - ### Constructor Detail

    - #### UniqueIdentifier

          public UniqueIdentifier(java.lang.String externalId,
                                  java.util.UUID id)

      This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.

      Parameters:
        `externalId` - Any existing weak identifier such as trade reference ID. This should be set here the first time a `class UniqueIdentifier` is created as part of state issuance, or ledger on-boarding activity. This ensure that the human readable identity is paired with the strong ID.
        `id` - Should never be set by user code and left as default initialised. So that the first time a state is issued this should be given a new UUID. Subsequent copies and evolutions of a state should just copy the externalId and id fields unmodified.

    - #### UniqueIdentifier

          public UniqueIdentifier()

      This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.

  - ### Method Detail

    - #### toString

          public java.lang.String toString()

    - #### compareTo

          public int compareTo(UniqueIdentifier other)

    - #### equals

          public boolean equals(java.lang.Object other)

    - #### hashCode

          public int hashCode()

    - #### getExternalId

          public java.lang.String getExternalId()

    - #### getId

          public java.util.UUID getId()

    - #### component1

          public java.lang.String component1()

    - #### component2

          public java.util.UUID component2()

    - #### copy

          public UniqueIdentifier copy(java.lang.String externalId,
                                       java.util.UUID id)

      This class provides a truly unique identifier of a trade, state, or other business object, bound to any existing external ID. Equality and comparison are based on the unique ID only; if two states somehow have the same UUID but different external IDs, it would indicate a problem with handling of IDs.

      Parameters:
        `externalId` - Any existing weak identifier such as trade reference ID. This should be set here the first time a `class UniqueIdentifier` is created as part of state issuance, or ledger on-boarding activity. This ensure that the human readable identity is paired with the strong ID.
        `id` - Should never be set by user code and left as default initialised. So that the first time a state is issued this should be given a new UUID. Subsequent copies and evolutions of a state should just copy the externalId and id fields unmodified.