commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [1/5] incubator-commonsrdf git commit: COMMONSRDF-14 specify hashCode
Date Mon, 10 Aug 2015 10:31:22 GMT
Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/master 3b0028621 -> 9c441e2c2


COMMONSRDF-14 specify hashCode


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/1a1bc326
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/1a1bc326
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/1a1bc326

Branch: refs/heads/master
Commit: 1a1bc326c9232b6d560c14d43c5e05a1e1e640b9
Parents: d44aee6
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Wed May 6 22:49:29 2015 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Tue May 12 10:05:09 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/BlankNode.java     |  4 ++++
 api/src/main/java/org/apache/commons/rdf/api/IRI.java  |  7 ++++++-
 .../main/java/org/apache/commons/rdf/api/Literal.java  | 11 +++++++++--
 .../main/java/org/apache/commons/rdf/api/Triple.java   | 13 ++++++++++---
 4 files changed, 29 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1a1bc326/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java b/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
index 52275ad..80ee79e 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/BlankNode.java
@@ -101,6 +101,10 @@ public interface BlankNode extends BlankNodeOrIRI {
 
     /**
      * Calculate a hash code for this BlankNode.
+     * <p>
+     * The returned hash code MUST be equal to the
+     * {@link String#hashCode()} of the
+     * {@link #uniqueReference()}.
      *
      * This method MUST be implemented in conjunction with
      * {@link #equals(Object)} so that two equal BlankNodes produce the same

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1a1bc326/api/src/main/java/org/apache/commons/rdf/api/IRI.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/IRI.java b/api/src/main/java/org/apache/commons/rdf/api/IRI.java
index 20ed071..117598e 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/IRI.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/IRI.java
@@ -60,8 +60,13 @@ public interface IRI extends BlankNodeOrIRI {
 
     /**
      * Calculate a hash code for this IRI.
+     * <p>
+     * The returned hash code MUST be equal to the
+     * {@link String#hashCode()} of the
+     * {@link #getIRIString()}.
      *
-     * This method MUST be implemented when implementing {@link #equals(Object)}
+     * This method MUST be implemented in conjunction with
+     * {@link #equals(Object)}
      * so that two equal IRIs produce the same hash code.
      *
      * @return a hash code value for this IRI.

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1a1bc326/api/src/main/java/org/apache/commons/rdf/api/Literal.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Literal.java b/api/src/main/java/org/apache/commons/rdf/api/Literal.java
index 8e22acb..970e9de 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/Literal.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/Literal.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rdf.api;
 
 import java.io.Serializable;
+import java.util.Objects;
 import java.util.Optional;
 
 /**
@@ -106,12 +107,18 @@ public interface Literal extends RDFTerm {
 
     /**
      * Calculate a hash code for this Literal.
-     *
-     * This method MUST be implemented when implementing {@link #equals(Object)}
+     * <p>
+     * The returned hash code MUST be equal to the result
+     * of {@link Objects#hash(Object...)} with
+     * the arguments
+     * {@link #getLexicalForm()}, {@link #getDatatype()}, {@link #getLanguageTag()}.
+     * <p>
+     * This method MUST be implemented in conjunction with {@link #equals(Object)}
      * so that two equal Literals produce the same hash code.
      *
      * @return a hash code value for this Literal.
      * @see Object#hashCode()
+     * @see Objects#hash(Object...)
      */
     @Override
     public int hashCode();

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/1a1bc326/api/src/main/java/org/apache/commons/rdf/api/Triple.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/Triple.java b/api/src/main/java/org/apache/commons/rdf/api/Triple.java
index f7dcd39..34ea7a3 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/Triple.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/Triple.java
@@ -17,6 +17,8 @@
  */
 package org.apache.commons.rdf.api;
 
+import java.util.Objects;
+
 /**
  * An <a href= "http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple" >RDF-1.1
  * Triple</a>, as defined by <a href= "http://www.w3.org/TR/rdf11-concepts/"
@@ -85,12 +87,17 @@ public interface Triple {
     /**
      * Calculate a hash code for this Triple.
      * <p>
-     * This method MUST be implemented when implementing {@link #equals(Object)}
-     * so that two equal IRIs produce the same hash code.
-     * </p>
+     * The returned hash code MUST be equal to the result
+     * of {@link Objects#hash(Object...)} with
+     * the arguments
+     * {@link #getSubject()}, {@link #getPredicate()}, {@link #getObject()}.
+     * <p>
+     * This method MUST be implemented in conjunction with {@link #equals(Object)}
+     * so that two equal {@link Triple}s produce the same hash code.
      *
      * @return a hash code value for this Triple.
      * @see Object#hashCode()
+     * @see Objects#hash(Object...)
      */
     @Override
     public int hashCode();


Mime
View raw message