Created
April 5, 2022 09:04
-
-
Save gunkim/90504dd8ecb92dc3eff86e715f46690f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun hashCodeOf(vararg values: Any?): Int = | |
values.fold(0) { acc, value -> | |
(acc * 31) + value.hashCode() | |
} | |
class Category( | |
val id: Long? = null, | |
val name: String, | |
val createdAt: LocalDateTime? = null, | |
val updatedAt: LocalDateTime? = null | |
) { | |
override fun equals(other: Any?): Boolean = this === other || | |
other is Category && | |
id == other.id && | |
name == other.name && | |
createdAt == other.createdAt && | |
updatedAt == other.updatedAt | |
override fun hashCode(): Int = hashCodeOf(id, name, createdAt, updatedAt) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment