mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-15 17:02:06 +01:00
Improve legibility of CertificationSet code
This commit is contained in:
parent
41f4e3c453
commit
f27f1133f7
1 changed files with 6 additions and 9 deletions
|
@ -90,26 +90,23 @@ class CertificationSet(
|
||||||
require(issuer.fingerprint == certification.issuer.fingerprint) { "Issuer fingerprint mismatch." }
|
require(issuer.fingerprint == certification.issuer.fingerprint) { "Issuer fingerprint mismatch." }
|
||||||
require(target.fingerprint == certification.target.fingerprint) { "Target fingerprint mismatch." }
|
require(target.fingerprint == certification.target.fingerprint) { "Target fingerprint mismatch." }
|
||||||
|
|
||||||
var certificationsForUserId: MutableList<Certification>? = _certifications[certification.userId]
|
val certificationsForUserId = _certifications.getOrPut(certification.userId) { mutableListOf() }
|
||||||
if (certificationsForUserId == null) {
|
|
||||||
certificationsForUserId = ArrayList()
|
|
||||||
_certifications[certification.userId] = certificationsForUserId
|
|
||||||
}
|
|
||||||
|
|
||||||
if (certificationsForUserId.isEmpty()) {
|
if (certificationsForUserId.isEmpty()) {
|
||||||
certificationsForUserId.add(certification)
|
certificationsForUserId.add(certification)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val existing = certificationsForUserId[0]
|
val existing = certificationsForUserId[0]
|
||||||
|
// if existing is older than this certification
|
||||||
if (existing.creationTime.before(certification.creationTime)) {
|
if (existing.creationTime.before(certification.creationTime)) {
|
||||||
certificationsForUserId.clear() // throw away older certifications
|
// throw away older certifications
|
||||||
|
certificationsForUserId.clear()
|
||||||
}
|
}
|
||||||
// If our certification is newest
|
// If this certification is newest (or equally old!)
|
||||||
if (!existing.creationTime.after(certification.creationTime)) {
|
if (!existing.creationTime.after(certification.creationTime)) {
|
||||||
certificationsForUserId.add(certification)
|
certificationsForUserId.add(certification)
|
||||||
}
|
}
|
||||||
// else this certification is older, so ignore
|
// else this certification is older, so don't add it
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
|
Loading…
Reference in a new issue