From 1c79952150ad92533ea5e3f63fed21b4d504f965 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Wed, 28 Jun 2023 20:48:40 +0200 Subject: [PATCH] Cherry-picked baa9d10fd2b1e8e07253f4f3576cfb5fff875c44 --- .../pgpainless/wot/dijkstra/sq/Certification.kt | 15 ++++----------- .../wot/dijkstra/sq/CertificationSet.kt | 6 +++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Certification.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Certification.kt index 35f14c08..45bb32a3 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Certification.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Certification.kt @@ -49,16 +49,9 @@ data class Certification( this(issuer, target, targetUserId, creationTime, null, true, 120, Depth.limited(0), RegexSet.wildcard()) override fun toString(): String { - val relation = if (userId != null) { - "certifies" - } else { - "delegates to" - } - val relationTarget = if (userId != null) { - "[$userId] ${target.fingerprint}" - } else { - "$target" - } - return "$issuer $relation $relationTarget" + return if (userId != null) + "$issuer certifies [$userId] ${target.fingerprint}" + else + "$issuer delegates to ${target.fingerprint}" } } \ No newline at end of file diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt index 9139fc83..e31f138d 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/CertificationSet.kt @@ -39,7 +39,7 @@ data class CertificationSet( * @param certification certification */ @JvmStatic - fun fromCertification(certification: Certification) : CertificationSet { + fun fromCertification(certification: Certification): CertificationSet { val set = empty(certification.issuer, certification.target) set.add(certification) return set @@ -72,7 +72,7 @@ data class CertificationSet( * * @param certification [Certification] with the same issuer fingerprint and target fingerprint as this object. */ - fun add(certification : Certification) { + fun add(certification: Certification) { require(issuer.fingerprint == certification.issuer.fingerprint) { "Issuer fingerprint mismatch." } require(target.fingerprint == certification.target.fingerprint) { "Target fingerprint mismatch." } @@ -85,6 +85,6 @@ data class CertificationSet( } override fun toString(): String { - return "$certifications" + return certifications.map { it.value }.flatten().joinToString("\n") } } \ No newline at end of file