Reputation: 15
Can somebody tell me how to best set the externalID
when creating a new UniqueIdentifier
? The below does not work.
UniqueIdentifier linearid = new UniqueIdentifier(stringVar);
Upvotes: 1
Views: 527
Reputation: 150
The following works in my Kotlin code:
val linearId = UniqueIdentifier("externalIdHere")
Looking at the function the UUID.randomUUID() should act as the default parameter for the id: https://github.com/corda/corda/blob/master/core/src/main/kotlin/net/corda/core/contracts/UniqueIdentifier.kt#L23
Upvotes: 0
Reputation: 408
You need to give the constructor a UUID also:
UniqueIdentifier linearid = new UniqueIdentifier(java.lang.String stringVar, java.util.UUID id);
And then to retrieve and use your id, you will call the getExternalId() method:
String myExternalId = linearid.getExternalId();
https://docs.corda.net/api/javadoc/net/corda/core/contracts/UniqueIdentifier.html
Upvotes: 1