From 461a2bebd44bef92710d375fbea7e70c213b50ef Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Thu, 29 Jun 2023 00:14:18 +0200 Subject: [PATCH] Path, Paths, RegexSet: Implement toString --- .../src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Path.kt | 4 ++++ .../src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Paths.kt | 4 +++- .../main/kotlin/org/pgpainless/wot/dijkstra/sq/RegexSet.kt | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Path.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Path.kt index e023eba0..d7cdc16f 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Path.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Path.kt @@ -120,4 +120,8 @@ class Path( residualDepth = certification.trustDepth.min(residualDepth.decrease(1)) edges.add(certification) } + + override fun toString(): String { + return "{${root.fingerprint}} => {${edges.map { it.target }.joinToString(" -> ")}} (residual {$residualDepth})" + } } \ No newline at end of file diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Paths.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Paths.kt index 77766f2c..1e806634 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Paths.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Paths.kt @@ -46,6 +46,8 @@ class Paths(private val _paths: MutableList) { * @param amount trust amount */ data class Item(val path: Path, val amount: Int) { - + override fun toString(): String { + return "$path ($amount)" + } } } \ No newline at end of file diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/RegexSet.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/RegexSet.kt index 91289e77..d9230db7 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/RegexSet.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/RegexSet.kt @@ -48,4 +48,8 @@ data class RegexSet(val regexStrings: Set) { Pattern.compile(it).matcher(string).find() } } + + override fun toString(): String { + return regexStrings.joinToString(", ") + } } \ No newline at end of file