commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject [2/4] incubator-commonsrdf git commit: Change fields to private and final per the classes being package private
Date Sat, 28 Mar 2015 05:02:25 GMT
Change fields to private and final per the classes being package private

There is no reason to allow for extensibility with package private
classes, so locking them down to prevent accidental situations where
this is possible

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

Branch: refs/heads/master
Commit: 2b72b84b1687d3dff80f0049b3d89cd7e251fb9a
Parents: 98df1c0
Author: Peter Ansell <p_ansell@yahoo.com>
Authored: Sat Mar 28 15:53:38 2015 +1100
Committer: Peter Ansell <p_ansell@yahoo.com>
Committed: Sat Mar 28 15:54:25 2015 +1100

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/simple/GraphImpl.java |  4 ++--
 .../java/org/apache/commons/rdf/simple/IRIImpl.java   | 14 +++++++++-----
 .../org/apache/commons/rdf/simple/LiteralImpl.java    |  2 +-
 .../org/apache/commons/rdf/simple/TripleImpl.java     |  8 ++++----
 4 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/2b72b84b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
index bcbc825..30ab15e 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
@@ -38,10 +38,10 @@ import org.apache.commons.rdf.api.Triple;
  * <p>
  * All Stream operations are performed using parallel and unordered directives.
  */
-class GraphImpl implements Graph {
+final class GraphImpl implements Graph {
 
 	private static final int TO_STRING_MAX = 10;
-	protected final Set<Triple> triples = new LinkedHashSet<Triple>();
+	private final Set<Triple> triples = new LinkedHashSet<Triple>();
 
 	@Override
 	public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/2b72b84b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
index 02d80d1..a735737 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/IRIImpl.java
@@ -21,18 +21,19 @@ import java.net.URI;
 
 import org.apache.commons.rdf.api.IRI;
 
-/** 
+/**
  * A simple implementation of IRI.
  *
  */
-class IRIImpl implements IRI {
+final class IRIImpl implements IRI {
 
-	protected String iri;
+	private final String iri;
 
 	public IRIImpl(String iri) {
 		// should throw IllegalArgumentException on most illegal IRIs
 		URI.create(iri);
-		// NOTE: We don't keep the URI as it uses outdated RFC2396 and will get some IDNs wrong
+		// NOTE: We don't keep the URI as it uses outdated RFC2396 and will get
+		// some IDNs wrong
 		this.iri = iri;
 	}
 
@@ -53,7 +54,10 @@ class IRIImpl implements IRI {
 
 	@Override
 	public boolean equals(Object obj) {
-		if (!(obj instanceof IRI)) {
+		if (this == obj) {
+			return true;
+		}
+		if (obj == null || !(obj instanceof IRI)) {
 			return false;
 		}
 		IRI other = (IRI) obj;

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/2b72b84b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
index b26cf6b..13c65ef 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/LiteralImpl.java
@@ -29,7 +29,7 @@ import org.apache.commons.rdf.api.Literal;
  * A simple implementation of Literal.
  *
  */
-class LiteralImpl implements Literal {
+final class LiteralImpl implements Literal {
 
 	private static final String QUOTE = "\"";
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/2b72b84b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
index fb6904d..6c9c825 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/TripleImpl.java
@@ -32,11 +32,11 @@ import org.apache.commons.rdf.api.Triple;
  * A simple implementation of Triple.
  *
  */
-class TripleImpl implements Triple {
+final class TripleImpl implements Triple {
 
-	private BlankNodeOrIRI subject;
-	private IRI predicate;
-	private RDFTerm object;
+	private final BlankNodeOrIRI subject;
+	private final IRI predicate;
+	private final RDFTerm object;
 
 	/**
 	 * Construct Triple from its constituent parts.


Mime
View raw message