ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1626218 - /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java
Date Fri, 19 Sep 2014 13:53:15 GMT
Author: seanfinan
Date: Fri Sep 19 13:53:15 2014
New Revision: 1626218

URL: http://svn.apache.org/r1626218
Log:
better hashcode

Modified:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java?rev=1626218&r1=1626217&r2=1626218&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/concept/Concept.java
Fri Sep 19 13:53:15 2014
@@ -26,6 +26,8 @@ final public class Concept {
    final private CollectionMap<ConceptCode, String> _codes;
    final private Collection<Integer> _ctakesSemantics;
 
+   final private int _hashcode;
+
    public Concept( final String cui ) {
       this( cui, "" );
    }
@@ -47,6 +49,7 @@ final public class Concept {
          ctakesSemantics.add( CONST.NE_TYPE_ID_UNKNOWN );
       }
       _ctakesSemantics = Collections.unmodifiableCollection( ctakesSemantics );
+      _hashcode = (cui + "_" + preferredText + "_" + codes.hashCode()).hashCode();
    }
 
    public String getCui() {
@@ -75,4 +78,24 @@ final public class Concept {
       return (_preferredText == null || _preferredText.isEmpty()) && _codes.isEmpty();
    }
 
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public boolean equals( final Object value ) {
+      return value instanceof Concept
+             && _cui.equals( ((Concept)value)._cui )
+             && _preferredText.equals( ((Concept)value)._preferredText )
+             && _codes.equals( ((Concept)value)._codes );
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public int hashCode() {
+      return _hashcode;
+   }
+
 }



Mime
View raw message