@@ -34,18 +34,33 @@ private[collection] object JavaCollectionWrappers extends Serializable {
34
34
def hasMoreElements = underlying.hasNext
35
35
def nextElement () = underlying.next()
36
36
override def remove () = throw new UnsupportedOperationException
37
+ override def equals (other : Any ): Boolean = other match {
38
+ case that : IteratorWrapper [_] => this .underlying == that.underlying
39
+ case _ => false
40
+ }
41
+ override def hashCode : Int = underlying.hashCode()
37
42
}
38
43
39
44
@ SerialVersionUID (3L )
40
45
class JIteratorWrapper [A ](val underlying : ju.Iterator [A ]) extends AbstractIterator [A ] with Iterator [A ] with Serializable {
41
46
def hasNext = underlying.hasNext
42
47
def next () = underlying.next
48
+ override def equals (other : Any ): Boolean = other match {
49
+ case that : JIteratorWrapper [_] => this .underlying == that.underlying
50
+ case _ => false
51
+ }
52
+ override def hashCode : Int = underlying.hashCode()
43
53
}
44
54
45
55
@ SerialVersionUID (3L )
46
56
class JEnumerationWrapper [A ](val underlying : ju.Enumeration [A ]) extends AbstractIterator [A ] with Iterator [A ] with Serializable {
47
57
def hasNext = underlying.hasMoreElements
48
58
def next () = underlying.nextElement
59
+ override def equals (other : Any ): Boolean = other match {
60
+ case that : JEnumerationWrapper [_] => this .underlying == that.underlying
61
+ case _ => false
62
+ }
63
+ override def hashCode : Int = underlying.hashCode()
49
64
}
50
65
51
66
trait IterableWrapperTrait [A ] extends ju.AbstractCollection [A ] {
@@ -57,13 +72,11 @@ private[collection] object JavaCollectionWrappers extends Serializable {
57
72
58
73
@ SerialVersionUID (3L )
59
74
class IterableWrapper [A ](val underlying : Iterable [A ]) extends ju.AbstractCollection [A ] with IterableWrapperTrait [A ] with Serializable {
60
- import scala .runtime .Statics ._
61
- override def equals (other : Any ): Boolean =
62
- other match {
63
- case other : IterableWrapper [_] => underlying.equals(other.underlying)
64
- case _ => false
65
- }
66
- override def hashCode = finalizeHash(mix(mix(0xcafebabe , " IterableWrapper" .hashCode), anyHash(underlying)), 1 )
75
+ override def equals (other : Any ): Boolean = other match {
76
+ case that : IterableWrapper [_] => this .underlying == that.underlying
77
+ case _ => false
78
+ }
79
+ override def hashCode : Int = underlying.hashCode()
67
80
}
68
81
69
82
@ SerialVersionUID (3L )
@@ -74,6 +87,11 @@ private[collection] object JavaCollectionWrappers extends Serializable {
74
87
def iterator = underlying.iterator.asScala
75
88
override def iterableFactory = mutable.ArrayBuffer
76
89
override def isEmpty : Boolean = ! underlying.iterator().hasNext
90
+ override def equals (other : Any ): Boolean = other match {
91
+ case that : JIterableWrapper [_] => this .underlying == that.underlying
92
+ case _ => false
93
+ }
94
+ override def hashCode : Int = underlying.hashCode()
77
95
}
78
96
79
97
@ SerialVersionUID (3L )
@@ -86,6 +104,11 @@ private[collection] object JavaCollectionWrappers extends Serializable {
86
104
override def knownSize : Int = if (underlying.isEmpty) 0 else super .knownSize
87
105
override def isEmpty = underlying.isEmpty
88
106
override def iterableFactory = mutable.ArrayBuffer
107
+ override def equals (other : Any ): Boolean = other match {
108
+ case that : JCollectionWrapper [_] => this .underlying == that.underlying
109
+ case _ => false
110
+ }
111
+ override def hashCode : Int = underlying.hashCode()
89
112
}
90
113
91
114
@ SerialVersionUID (3L )
@@ -254,7 +277,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
254
277
def getKey = k
255
278
def getValue = v
256
279
def setValue (v1 : V ) = self.put(k, v1)
257
-
280
+
258
281
// It's important that this implementation conform to the contract
259
282
// specified in the javadocs of java.util.Map.Entry.hashCode
260
283
//
0 commit comments