mirror of https://github.com/usbharu/Hideout.git
fix: equalsを修正
This commit is contained in:
parent
e8b6b6784c
commit
3eb310f306
|
@ -14,21 +14,6 @@ open class Emoji(
|
|||
HasName,
|
||||
HasId {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is Emoji) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
if (updated != other.updated) return false
|
||||
return icon == other.icon
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + updated.hashCode()
|
||||
result = 31 * result + icon.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "Emoji(" +
|
||||
|
@ -40,5 +25,29 @@ open class Emoji(
|
|||
" ${super.toString()}"
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as Emoji
|
||||
|
||||
if (name != other.name) return false
|
||||
if (id != other.id) return false
|
||||
if (updated != other.updated) return false
|
||||
if (icon != other.icon) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
result = 31 * result + updated.hashCode()
|
||||
result = 31 * result + icon.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -73,5 +73,20 @@ class APResourceResolveServiceImpl(
|
|||
override suspend fun statusMessage(): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as APResolveResponse<*>
|
||||
|
||||
return objects == other.objects
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return objects.hashCode()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,27 @@ open class SnowflakeIdGenerateService(private val baseTime: Long) : IdGenerateSe
|
|||
}
|
||||
|
||||
private fun getTime(): Long = Instant.now().toEpochMilli()
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as SnowflakeIdGenerateService
|
||||
|
||||
if (baseTime != other.baseTime) return false
|
||||
if (lastTimeStamp != other.lastTimeStamp) return false
|
||||
if (sequenceId != other.sequenceId) return false
|
||||
if (mutex != other.mutex) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = baseTime.hashCode()
|
||||
result = 31 * result + lastTimeStamp.hashCode()
|
||||
result = 31 * result + sequenceId
|
||||
result = 31 * result + mutex.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,42 @@ package dev.usbharu.hideout.core.domain.model.instance
|
|||
class Nodeinfo private constructor() {
|
||||
|
||||
var links: List<Links> = emptyList()
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Nodeinfo
|
||||
|
||||
return links == other.links
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return links.hashCode()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Links private constructor() {
|
||||
var rel: String? = null
|
||||
var href: String? = null
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Links
|
||||
|
||||
if (rel != other.rel) return false
|
||||
if (href != other.href) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = rel?.hashCode() ?: 0
|
||||
result = 31 * result + (href?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,14 +6,71 @@ package dev.usbharu.hideout.core.domain.model.instance
|
|||
class Nodeinfo2_0 {
|
||||
var metadata: Metadata? = null
|
||||
var software: Software? = null
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Nodeinfo2_0
|
||||
|
||||
if (metadata != other.metadata) return false
|
||||
if (software != other.software) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = metadata?.hashCode() ?: 0
|
||||
result = 31 * result + (software?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Metadata {
|
||||
var nodeName: String? = null
|
||||
var nodeDescription: String? = null
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Metadata
|
||||
|
||||
if (nodeName != other.nodeName) return false
|
||||
if (nodeDescription != other.nodeDescription) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = nodeName?.hashCode() ?: 0
|
||||
result = 31 * result + (nodeDescription?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Software {
|
||||
var name: String? = null
|
||||
var version: String? = null
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Software
|
||||
|
||||
if (name != other.name) return false
|
||||
if (version != other.version) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = name?.hashCode() ?: 0
|
||||
result = 31 * result + (version?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,4 +19,24 @@ class HttpSignatureVerifierComposite(
|
|||
|
||||
throw IllegalArgumentException("Unsupported algorithm. ${signature.algorithm}")
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as HttpSignatureVerifierComposite
|
||||
|
||||
if (map != other.map) return false
|
||||
if (httpSignatureHeaderParser != other.httpSignatureHeaderParser) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = map.hashCode()
|
||||
result = 31 * result + httpSignatureHeaderParser.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,22 @@ class UserDetailsImpl(
|
|||
" ${super.toString()}"
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as UserDetailsImpl
|
||||
|
||||
return id == other.id
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + id.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,73 @@
|
|||
package dev.usbharu.hideout.core.service.media
|
||||
|
||||
sealed class SavedMedia(val success: Boolean)
|
||||
sealed class SavedMedia(val success: Boolean) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as SavedMedia
|
||||
|
||||
return success == other.success
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return success.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
class SuccessSavedMedia(
|
||||
val name: String,
|
||||
val url: String,
|
||||
val thumbnailUrl: String,
|
||||
) :
|
||||
SavedMedia(true)
|
||||
SavedMedia(true) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as SuccessSavedMedia
|
||||
|
||||
if (name != other.name) return false
|
||||
if (url != other.url) return false
|
||||
if (thumbnailUrl != other.thumbnailUrl) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + url.hashCode()
|
||||
result = 31 * result + thumbnailUrl.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class FaildSavedMedia(
|
||||
val reason: String,
|
||||
val description: String,
|
||||
val trace: Throwable? = null
|
||||
) : SavedMedia(false)
|
||||
) : SavedMedia(false) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as FaildSavedMedia
|
||||
|
||||
if (reason != other.reason) return false
|
||||
if (description != other.description) return false
|
||||
if (trace != other.trace) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = super.hashCode()
|
||||
result = 31 * result + reason.hashCode()
|
||||
result = 31 * result + description.hashCode()
|
||||
result = 31 * result + (trace?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,25 @@ class KtorResolveResponse(val ktorHttpResponse: HttpResponse) : ResolveResponse
|
|||
override suspend fun header(): Map<String, List<String>> = ktorHttpResponse.headers.toMap()
|
||||
override suspend fun status(): Int = ktorHttpResponse.status.value
|
||||
override suspend fun statusMessage(): String = ktorHttpResponse.status.description
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as KtorResolveResponse
|
||||
|
||||
if (ktorHttpResponse != other.ktorHttpResponse) return false
|
||||
if (_bodyAsText != other._bodyAsText) return false
|
||||
if (!_bodyAsBytes.contentEquals(other._bodyAsBytes)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = ktorHttpResponse.hashCode()
|
||||
result = 31 * result + _bodyAsText.hashCode()
|
||||
result = 31 * result + _bodyAsBytes.contentHashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,4 +9,19 @@ class TempFile<T : Path?>(val path: T) : AutoCloseable {
|
|||
override fun close() {
|
||||
path?.let { Files.deleteIfExists(it) }
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as TempFile<*>
|
||||
|
||||
return path == other.path
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return path?.hashCode() ?: 0
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue