Skip to content

Commit

Permalink
Implement hashCode alongside equals
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwalker committed Apr 9, 2015
1 parent 3885dc7 commit 858225b
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions modules/core/src/main/scala/rx/redis/resp/dataType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ case class RespArray(elements: Array[RespType]) extends RespType {
util.Arrays.equals(elements.asInstanceOf[Array[AnyRef]], other.asInstanceOf[Array[AnyRef]])
case _ super.equals(obj)
}
override def hashCode(): Int =
util.Arrays.hashCode(elements.asInstanceOf[Array[AnyRef]])
}

case class RespBytes(bytes: Array[Byte]) extends RespType {
Expand All @@ -52,6 +54,9 @@ case class RespBytes(bytes: Array[Byte]) extends RespType {
case _ super.equals(obj)
}

override def hashCode(): Int =
util.Arrays.hashCode(bytes)

override def toString: String = new String(bytes, Utf8)

def toString(charset: Charset): String = new String(bytes, charset)
Expand All @@ -71,15 +76,3 @@ case object NullString extends RespType {
case object NullArray extends RespType {
override def toString: String = "NULL"
}

//sealed abstract class ErrorType extends RespType
//
//case object NotEnoughData extends ErrorType {
// override def toString: String = "[INCOMPLETE]"
//}
//case class ProtocolError(pos: Int, found: Char, expected: List[Byte]) extends ErrorType {
// override def toString: String = {
// val e = expected mkString ", "
// s"Protocol error at char $pos, expected [$e], but found [$found]"
// }
//}

0 comments on commit 858225b

Please sign in to comment.