mirror of
https://github.com/corda/corda.git
synced 2025-04-07 19:34:41 +00:00
CORDA-2098: State pointers are now comparable. (#4494)
* State pointers are now data classes, so now comparable. * Pointers now are not data classes. Implemented hashCode and equals for comparability.
This commit is contained in:
parent
93d256649f
commit
eea348768b
@ -65,6 +65,19 @@ class StaticPointer<T : ContractState>(override val pointer: StateRef, override
|
||||
override fun resolve(ltx: LedgerTransaction): StateAndRef<T> {
|
||||
return ltx.referenceInputRefsOfType(type).single { pointer == it.ref }
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is StaticPointer<*>) return false
|
||||
|
||||
if (pointer != other.pointer) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return pointer.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,4 +131,17 @@ class LinearPointer<T : LinearState>(override val pointer: UniqueIdentifier, ove
|
||||
override fun resolve(ltx: LedgerTransaction): StateAndRef<T> {
|
||||
return ltx.referenceInputRefsOfType(type).single { pointer == it.state.data.linearId }
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is LinearPointer<*>) return false
|
||||
|
||||
if (pointer != other.pointer) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return pointer.hashCode()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user