Author: bblfish
Date: Wed Jun 22 22:07:22 2011
New Revision: 1138657

URL: http://svn.apache.org/viewvc?rev=1138657&view=rev
Log:
CLEREZZA-510 fixed equality and hash code. Reto correctly pointed out that hash 
code was not following the signature of TypedLiteral, and equals being 
identical with String breaks the symmetry with String.equals. Sadly...

Modified:
    
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala

Modified: 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala?rev=1138657&r1=1138656&r2=1138657&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
 (original)
+++ 
incubator/clerezza/trunk/parent/rdf.scala.utils/src/main/scala/org/apache/clerezza/rdf/scala/utils/EasyGraph.scala
 Wed Jun 22 22:07:22 2011
@@ -35,7 +35,7 @@ object EasyGraph {
 
        private val litFactory = LiteralFactory.getInstance
 
-       implicit def string2litBuilder(str: String) = new EzLiteral(str)
+       implicit def string2lit(str: String) = new EzLiteral(str)
 
        implicit def lit2String(lit: Literal) = lit.getLexicalForm
 
@@ -89,12 +89,11 @@ class EzLiteral(lexicalForm: String) ext
        override def equals(other: Any) = {
       other match {
                        case olit: TypedLiteral => (olit eq this) || 
(olit.getLexicalForm == lexicalForm && olit.getDataType == this.getDataType)
-                       case ostr: String => ostr == lexicalForm
                        case _ => false
                }
        }
 
-       override def hashCode() = lexicalForm.hashCode()
+       override def hashCode() = XSD.string.hashCode() +lexicalForm.hashCode()
 
        def getDataType = XSD.string
 }


Reply via email to