jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/5] jena git commit: Improve .equals
Date Mon, 29 Dec 2014 16:20:38 GMT
Improve .equals

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/ab93003b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/ab93003b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/ab93003b

Branch: refs/heads/master
Commit: ab93003b17bdcf727319269d6eba33f75a4c52f3
Parents: af9a2fd
Author: Andy Seaborne <andy@apache.org>
Authored: Mon Dec 29 13:05:19 2014 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon Dec 29 13:05:19 2014 +0000

----------------------------------------------------------------------
 .../hpl/jena/sparql/expr/aggregate/AggCountVar.java   |  1 +
 .../sparql/expr/aggregate/AggCountVarDistinct.java    |  1 +
 .../hp/hpl/jena/sparql/expr/aggregate/AggCustom.java  | 14 +++++++++++---
 .../jena/sparql/expr/aggregate/AggGroupConcat.java    |  1 +
 .../sparql/expr/aggregate/AggGroupConcatDistinct.java |  1 +
 .../jena/sparql/expr/aggregate/AggregatorBase.java    |  1 +
 6 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/ab93003b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVar.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVar.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVar.java
index 7163f6d..c802a64 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVar.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVar.java
@@ -45,6 +45,7 @@ public class AggCountVar extends AggregatorBase
     @Override
     public boolean equals(Object other)
     {
+        if ( this == other ) return true ;
         if ( ! ( other instanceof AggCountVar ) )
             return false ;
         AggCountVar agg = (AggCountVar)other ;

http://git-wip-us.apache.org/repos/asf/jena/blob/ab93003b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVarDistinct.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVarDistinct.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVarDistinct.java
index 1b171ee..7f92993 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVarDistinct.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCountVarDistinct.java
@@ -48,6 +48,7 @@ public class AggCountVarDistinct extends AggregatorBase
     @Override
     public boolean equals(Object other)
     {
+        if ( this == other ) return true ;
         if ( ! ( other instanceof AggCountVarDistinct ) )
             return false ;
         AggCountVarDistinct agg = (AggCountVarDistinct)other ;

http://git-wip-us.apache.org/repos/asf/jena/blob/ab93003b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
index 9dcf04a..72a78bc 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
@@ -21,6 +21,7 @@ package com.hp.hpl.jena.sparql.expr.aggregate;
 import java.util.Locale ;
 
 import org.apache.jena.atlas.io.IndentedLineBuffer ;
+import org.apache.jena.atlas.lib.Lib ;
 
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.query.QueryExecException ;
@@ -112,12 +113,19 @@ public class AggCustom extends AggregatorBase
     public String getIRI()                  { return iri ; }
 
     @Override
-    public int hashCode()   { return HC_AggNull ; }
+    public int hashCode()   { return HC_AggCustom ^ getExprList().hashCode() ^ iri.hashCode()
; }
+    
     @Override
     public boolean equals(Object other)
     {
-        if ( this == other ) return true ; 
-        return ( other instanceof AggCustom ) ;
+        if ( this == other ) return true ;
+        if ( ! ( other instanceof AggCustom ) )
+            return false ;
+        AggCustom agg = (AggCustom)other ;
+        return 
+            Lib.equal(this.iri, agg.iri) &&
+            this.isDistinct == agg.isDistinct &&
+            Lib.equal(this.getExprList(), agg.getExprList()) ;
     } 
 
     public static Accumulator createAccNull() { return new  AccCustom() ; }

http://git-wip-us.apache.org/repos/asf/jena/blob/ab93003b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcat.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcat.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcat.java
index 0a3c3d5..d5f9ad5 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcat.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcat.java
@@ -126,6 +126,7 @@ public class AggGroupConcat extends AggregatorBase
     @Override
     public boolean equals(Object other)
     {
+        if ( this == other ) return true ;
         if ( ! ( other instanceof AggGroupConcat ) )
             return false ;
         AggGroupConcat agg = (AggGroupConcat)other ;

http://git-wip-us.apache.org/repos/asf/jena/blob/ab93003b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcatDistinct.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcatDistinct.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcatDistinct.java
index ebef4b6..f1dbaf0 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcatDistinct.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggGroupConcatDistinct.java
@@ -77,6 +77,7 @@ public class AggGroupConcatDistinct extends AggregatorBase
     @Override
     public boolean equals(Object other)
     {
+        if ( this == other ) return true ;
         if ( ! ( other instanceof AggGroupConcatDistinct ) )
             return false ;
         AggGroupConcatDistinct agg = (AggGroupConcatDistinct)other ;

http://git-wip-us.apache.org/repos/asf/jena/blob/ab93003b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggregatorBase.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggregatorBase.java
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggregatorBase.java
index 919746d..f576f0a 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggregatorBase.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggregatorBase.java
@@ -174,5 +174,6 @@ public abstract class AggregatorBase implements Aggregator
     protected static final int HC_AggGroupConcatDistinct    =  0x17F ;
     
     protected static final int HC_AggNull                   =  0x180 ;
+    protected static final int HC_AggCustom                 =  0x181 ;
     
 }


Mime
View raw message