trait
MapEqualityConstraints
extends AnyRef
Value Members
-
def
!=
(arg0: AnyRef): Boolean
-
def
!=
(arg0: Any): Boolean
-
def
##
(): Int
-
def
==
(arg0: AnyRef): Boolean
-
def
==
(arg0: Any): Boolean
-
def
asInstanceOf
[T0]
: T0
-
def
clone
(): AnyRef
-
def
eq
(arg0: AnyRef): Boolean
-
def
equals
(arg0: Any): Boolean
-
def
finalize
(): Unit
-
def
getClass
(): java.lang.Class[_]
-
def
hashCode
(): Int
-
def
isInstanceOf
[T0]
: Boolean
-
implicit def
mapEqualityConstraint
[EAK, EAV, CA[_, _] <: scala.collection.GenMap[_, _], EBK, EBV, CB[_, _] <: scala.collection.GenMap[_, _]]
(implicit equalityOfA: Equality[CA[EAK, EAV]], evKey: EqualityConstraint[EAK, EBK], evValue: EqualityConstraint[EAV, EBV]): EqualityConstraint[CA[EAK, EAV], CB[EBK, EBV]]
-
def
ne
(arg0: AnyRef): Boolean
-
def
notify
(): Unit
-
def
notifyAll
(): Unit
-
def
synchronized
[T0]
(arg0: ⇒ T0): T0
-
def
toString
(): String
-
def
wait
(): Unit
-
def
wait
(arg0: Long, arg1: Int): Unit
-
def
wait
(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
Provides an implicit method that loosens the equality constraint defined by
TypeCheckedTripleEquals
orConversionCheckedTripleEquals
for ScalaMap
s to one that more closely matches Scala's approach toMap
equality.Scala's approach to
Map
equality is that if both objects being compared areMap
s, the elements are compared to determine equality. This means you could compare an immutableTreeMap
and a mutableHashMap
for equality, for instance, and get true so long as the two maps contained the same key-value mappings. Here's an example:Such a comparison would not, however, compile if you used
===
under eitherTypeCheckedTripleEquals
orConversionCheckedTripleEquals
, becauseTreeMap
andHashMap
are not in a subtype/supertype relationship, nor does an implicit conversion by default exist between them:If you mix or import the implicit conversion provided by
MapEqualityConstraint
, however, the comparison will be allowed:The equality constraint provided by this trait requires that both left and right sides are subclasses of
scala.collection.GenMap
and that anEqualityConstraint
can be found for both key types and both value types. In the example above, both theTreeMap
andHashMap
are subclasses ofscala.collection.GenMap
, and the regularTypeCheckedTripleEquals
provides equality constraints for the key types, both of which areString
, and value types, both of which areInt
. By contrast, this trait would not allow aTreeMap[String, Int]
to be compared against aHashMap[String, java.util.Date]
, because no equality constraint will exist between the value typesInt
andDate
: