lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1524591 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/expressions/ lucene/expressions/src/java/org/apache/lucene/expressions/ lucene/expressions/src/test/org/apache/lucene/expressions/
Date Wed, 18 Sep 2013 21:56:55 GMT
Author: rmuir
Date: Wed Sep 18 21:56:55 2013
New Revision: 1524591

URL: http://svn.apache.org/r1524591
Log:
LUCENE-5220: ExpressionSortField has crappy toString/bad equals/hashcode

Added:
    lucene/dev/branches/branch_4x/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSortField.java
      - copied unchanged from r1524588, lucene/dev/trunk/lucene/expressions/src/test/org/apache/lucene/expressions/TestExpressionSortField.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/expressions/   (props changed)
    lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionSortField.java

Modified: lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionSortField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionSortField.java?rev=1524591&r1=1524590&r2=1524591&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionSortField.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/expressions/src/java/org/apache/lucene/expressions/ExpressionSortField.java
Wed Sep 18 21:56:55 2013
@@ -37,6 +37,41 @@ class ExpressionSortField extends SortFi
   }
 
   @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = super.hashCode();
+    result = prime * result + ((source == null) ? 0 : source.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) return true;
+    if (!super.equals(obj)) return false;
+    if (getClass() != obj.getClass()) return false;
+    ExpressionSortField other = (ExpressionSortField) obj;
+    if (source == null) {
+      if (other.source != null) return false;
+    } else if (!source.equals(other.source)) return false;
+    return true;
+  }
+
+  @Override
+  public String toString() {
+    StringBuilder buffer = new StringBuilder();
+    
+    buffer.append("<expr \"");
+    buffer.append(getField());
+    buffer.append("\">");
+    
+    if (getReverse()) {
+      buffer.append('!');
+    }
+
+    return buffer.toString();
+  }
+
+  @Override
   public boolean needsScores() {
     return true; // TODO: maybe we can optimize by "figuring this out" somehow...
   }



Mime
View raw message