UniqueIdentifier
Keywords: net.corda.core.contracts.UniqueIdentifier class
Date: 2023-09-18

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.

- - ### Field Detail

    - #### Companion

          public static net.corda.core.contracts.UniqueIdentifier.Companion Companion

  - ### Constructor Detail

    - #### UniqueIdentifier

          @JvmOverloads
          public UniqueIdentifier(@Nullable
                                                java.lang.String externalId,
                                                @NotNull
                                                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

          @JvmOverloads
          public UniqueIdentifier(@Nullable
                                                java.lang.String externalId)

      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.

    - #### UniqueIdentifier

          @JvmOverloads
          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

          @NotNull
          public java.lang.String toString()

    - #### compareTo

          public int compareTo(@NotNull
                               UniqueIdentifier other)

    - #### equals

          public boolean equals(@Nullable
                                java.lang.Object other)

    - #### hashCode

          public int hashCode()

    - #### getExternalId

          @Nullable
          public java.lang.String getExternalId()

      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.

      See Also:
        `class UniqueIdentifier`

    - #### getId

          @NotNull
          public java.util.UUID getId()

      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.

    - #### component1

          @Nullable
          public java.lang.String component1()

      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.

      See Also:
        `class UniqueIdentifier`

    - #### component2

          @NotNull
          public java.util.UUID component2()

      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.

    - #### copy

          @NotNull
          public UniqueIdentifier copy(@Nullable
                                                java.lang.String externalId,
                                                @NotNull
                                                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.