From 423183bece8fd3772c8459862aa6c0099c817069 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 3 Jul 2023 15:44:39 +0200 Subject: [PATCH] Add equals() and hashCode() methods to Depth --- .../kotlin/org/pgpainless/wot/dijkstra/sq/Depth.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Depth.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Depth.kt index 2ca59152..9e43c0ad 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Depth.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/sq/Depth.kt @@ -93,7 +93,19 @@ class Depth(val limit: Int?) : Comparable { } } + override fun equals(other: Any?): Boolean { + if (other !is Depth) { + return false + } + + return limit == other.limit + } + override fun toString() : String { return if (isUnconstrained()) { "unconstrained" } else { limit!!.toString() } } + + override fun hashCode(): Int { + return limit ?: 0 + } } \ No newline at end of file