Skip to content

Commit 6c53872

Browse files
committed
hashCode and equals for Bus class
1 parent ce9c51f commit 6c53872

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

channel-event-bus/src/commonMain/kotlin/com/hoc081098/channeleventbus/ChannelEventBus.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ private class Bus private constructor(
136136
val channel: Channel<Any>,
137137
val isCollecting: Boolean,
138138
) {
139-
fun copy(isCollecting: Boolean = this.isCollecting): Bus = Bus(channel, isCollecting)
139+
fun copy(isCollecting: Boolean): Bus = Bus(channel, isCollecting)
140+
141+
override fun hashCode() = 31 * channel.hashCode() + isCollecting.hashCode()
142+
143+
override fun equals(other: Any?): Boolean {
144+
if (this === other) return true
145+
if (other !is Bus) return false
146+
return channel == other.channel && isCollecting == other.isCollecting
147+
}
140148

141149
override fun toString(): String = "${super.toString()}($channel, $isCollecting)"
142150

0 commit comments

Comments
 (0)