Skip to content

Commit d9e5f34

Browse files
author
Adrián García
committed
Add equals and hashCode to Resource
1 parent b6ba32d commit d9e5f34

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mini-common/src/main/java/mini/Resource.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ open class Resource<out T> @PublishedApi internal constructor(val value: Any?) {
5656
override fun toString(): String {
5757
return value.toString()
5858
}
59+
60+
override fun equals(other: Any?): Boolean {
61+
if (this === other) return true
62+
if (javaClass != other?.javaClass) return false
63+
64+
other as Resource<*>
65+
66+
if (value != other.value) return false
67+
68+
return true
69+
}
70+
71+
override fun hashCode(): Int = value?.hashCode() ?: 0
5972
}
6073

6174
/**

0 commit comments

Comments
 (0)