From fc53b199150fbd2c25b175a344e17d82cfc839ea Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 18 Mar 2023 18:20:00 +0200 Subject: [PATCH] Add toString to models --- .../koitharu/kotatsu/parsers/model/Manga.kt | 6 +- .../kotatsu/parsers/model/MangaChapter.kt | 6 +- .../kotatsu/parsers/model/MangaPage.kt | 76 +++++++++---------- .../kotatsu/parsers/model/MangaTag.kt | 6 +- 4 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/Manga.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/Manga.kt index 9186be16..0f45a992 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/Manga.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/Manga.kt @@ -155,4 +155,8 @@ class Manga( result = 31 * result + source.hashCode() return result } -} \ No newline at end of file + + override fun toString(): String { + return "Manga($id - \"$title\" [$url] - $source)" + } +} diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaChapter.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaChapter.kt index 52b01e6b..4059be66 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaChapter.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaChapter.kt @@ -67,4 +67,8 @@ class MangaChapter( result = 31 * result + source.hashCode() return result } -} \ No newline at end of file + + override fun toString(): String { + return "MangaChapter($id - #$number [$url] - $source)" + } +} diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaPage.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaPage.kt index 0c5102a0..b741fac3 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaPage.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaPage.kt @@ -3,49 +3,45 @@ package org.koitharu.kotatsu.parsers.model import org.koitharu.kotatsu.parsers.MangaParser class MangaPage( - /** - * Unique identifier for manga - */ - val id: Long, - /** - * Relative url to page (**without** a domain) or any other uri. - * Used principally in parsers. - * May contain link to image or html page. - * @see MangaParser.getPageUrl - */ - val url: String, - /** - * Absolute link to the chapter or website home page. - * Used in Referer header - */ - @Deprecated("Referer header should be added based on source domain") - val referer: String, - /** - * Absolute url of the small page image if exists, null otherwise - */ - val preview: String?, - val source: MangaSource, + /** + * Unique identifier for manga + */ + val id: Long, + /** + * Relative url to page (**without** a domain) or any other uri. + * Used principally in parsers. + * May contain link to image or html page. + * @see MangaParser.getPageUrl + */ + val url: String, + /** + * Absolute url of the small page image if exists, null otherwise + */ + val preview: String?, + val source: MangaSource, ) { - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false - other as MangaPage + other as MangaPage - if (id != other.id) return false - if (url != other.url) return false - if (referer != other.referer) return false - if (preview != other.preview) return false - return source == other.source - } + if (id != other.id) return false + if (url != other.url) return false + if (preview != other.preview) return false + return source == other.source + } - override fun hashCode(): Int { - var result = id.hashCode() - result = 31 * result + url.hashCode() - result = 31 * result + referer.hashCode() - result = 31 * result + (preview?.hashCode() ?: 0) - result = 31 * result + source.hashCode() - return result - } + override fun hashCode(): Int { + var result = id.hashCode() + result = 31 * result + url.hashCode() + result = 31 * result + (preview?.hashCode() ?: 0) + result = 31 * result + source.hashCode() + return result + } + + override fun toString(): String { + return "MangaPage($id [$url] - $source)" + } } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaTag.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaTag.kt index 0d9fa04b..be0f9083 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaTag.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/model/MangaTag.kt @@ -34,4 +34,8 @@ class MangaTag( result = 31 * result + source.hashCode() return result } -} \ No newline at end of file + + override fun toString(): String { + return "MangaTag($key \"$title\" - $source)" + } +}