commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject commons-rdf git commit: No need to nest in else clause.
Date Mon, 30 Oct 2017 16:59:45 GMT
Repository: commons-rdf
Updated Branches:
  refs/heads/master d77f8dd45 -> 9285480e7


No need to nest in else clause.

Project: http://git-wip-us.apache.org/repos/asf/commons-rdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rdf/commit/9285480e
Tree: http://git-wip-us.apache.org/repos/asf/commons-rdf/tree/9285480e
Diff: http://git-wip-us.apache.org/repos/asf/commons-rdf/diff/9285480e

Branch: refs/heads/master
Commit: 9285480e74acd8bf56545c454eb8e1d41f2aa42f
Parents: d77f8dd
Author: Gary Gregory <ggregory@apache.org>
Authored: Mon Oct 30 10:59:41 2017 -0600
Committer: Gary Gregory <ggregory@apache.org>
Committed: Mon Oct 30 10:59:41 2017 -0600

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/DummyDataset.java   |  6 ++----
 .../java/org/apache/commons/rdf/api/DummyGraph.java     |  3 +--
 .../org/apache/commons/rdf/jsonldjava/JsonLdRDF.java    | 12 +++++-------
 .../apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java    |  3 +--
 .../apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java   |  7 +++----
 .../commons/rdf/rdf4j/impl/RepositoryGraphImpl.java     |  7 +++----
 .../java/org/apache/commons/rdf/simple/DatasetImpl.java |  6 ++----
 .../java/org/apache/commons/rdf/simple/GraphImpl.java   |  9 +++------
 8 files changed, 20 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyDataset.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyDataset.java b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyDataset.java
index 0fa2703..66efcf2 100644
--- a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyDataset.java
+++ b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyDataset.java
@@ -84,9 +84,8 @@ class DummyDataset implements Dataset {
         filteredStreamCalled = true;
         if (contains(graphName, subject, predicate, object)) {
             return Stream.of(new DummyQuad());
-        } else {
-            return Stream.empty();
         }
+        return Stream.empty();
     }
 
     @Override
@@ -98,9 +97,8 @@ class DummyDataset implements Dataset {
     public Optional<Graph> getGraph(final BlankNodeOrIRI graphName) {
         if (graphName == null) {
             return Optional.of(getGraph());
-        } else {
-            return Optional.empty();
         }
+        return Optional.empty();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyGraph.java
----------------------------------------------------------------------
diff --git a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyGraph.java b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyGraph.java
index 7cb0f3e..1e5ff51 100644
--- a/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyGraph.java
+++ b/commons-rdf-api/src/test/java/org/apache/commons/rdf/api/DummyGraph.java
@@ -78,8 +78,7 @@ class DummyGraph implements Graph {
         filteredStreamCalled = true;
         if (contains(subject, predicate, object)) {
             return Stream.of(new DummyTriple());
-        } else {
-            return Stream.empty();
         }
+        return Stream.empty();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDF.java
----------------------------------------------------------------------
diff --git a/commons-rdf-jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDF.java
b/commons-rdf-jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDF.java
index cb77a0e..fc26046 100644
--- a/commons-rdf-jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDF.java
+++ b/commons-rdf-jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/JsonLdRDF.java
@@ -280,12 +280,11 @@ public final class JsonLdRDF implements RDF {
                 // One of ours (but possibly not a JsonLdBlankNode) -
                 // we can use the suffix directly
                 return ref.replace(bnodePrefix, "");
-            } else {
-                // Map to unique bnode identifier, e.g.
-                // _:0dbd92ee-ab1a-45e7-bba2-7ade54f87ec5
-                final UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
-                return "_:" + uuid;
             }
+            // Map to unique bnode identifier, e.g.
+            // _:0dbd92ee-ab1a-45e7-bba2-7ade54f87ec5
+            final UUID uuid = UUID.nameUUIDFromBytes(ref.getBytes(StandardCharsets.UTF_8));
+            return "_:" + uuid;
         } else {
             throw new IllegalArgumentException("Expected a BlankNode or IRI, not: " + blankNodeOrIRI);
         }
@@ -303,9 +302,8 @@ public final class JsonLdRDF implements RDF {
             // TODO: Our own JsonLdLiteral
             if (node.getLanguage() != null) {
                 return createLiteral(node.getValue(), node.getLanguage());
-            } else {
-                return createLiteral(node.getValue(), createIRI(node.getDatatype()));
             }
+            return createLiteral(node.getValue(), createIRI(node.getDatatype()));
         } else {
             throw new IllegalArgumentException("Node is neither IRI, BlankNode nor Literal:
" + node);
         }

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
b/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
index 58f00c7..b50ccf7 100644
--- a/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
+++ b/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/BlankNodeImpl.java
@@ -80,9 +80,8 @@ final class BlankNodeImpl extends AbstractRDFTerm<BNode> implements
RDF4JBlankNo
     public String ntriplesString() {
         if (isValidBlankNodeLabel(value.getID())) {
             return "_:" + value.getID();
-        } else {
-            return "_:" + UUID.nameUUIDFromBytes(value.getID().getBytes(StandardCharsets.UTF_8));
         }
+        return "_:" + UUID.nameUUIDFromBytes(value.getID().getBytes(StandardCharsets.UTF_8));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
b/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
index f8753fb..60429b0 100644
--- a/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
+++ b/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/ModelGraphImpl.java
@@ -100,11 +100,10 @@ final class ModelGraphImpl implements RDF4JGraph {
         final int size = model.size();
         if (size < Integer.MAX_VALUE) {
             return size;
-        } else {
-            // TODO: Check if this can really happen with RDF4J models
-            // Collection.size() can't help us, we'll have to count
-            return model.parallelStream().count();
         }
+        // TODO: Check if this can really happen with RDF4J models
+        // Collection.size() can't help us, we'll have to count
+        return model.parallelStream().count();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
b/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
index 644e39c..f25dc26 100644
--- a/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
+++ b/commons-rdf-rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
@@ -91,10 +91,9 @@ class RepositoryGraphImpl extends AbstractRepositoryGraphLike<Triple>
implements
             try (RepositoryConnection conn = getRepositoryConnection()) {
                 return conn.size();
             }
-        } else {
-            try (Stream<RDF4JTriple> stream = stream()) {
-                return stream.count();
-            }
+        }
+        try (Stream<RDF4JTriple> stream = stream()) {
+            return stream.count();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
index 89cea0f..94d57e3 100644
--- a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
+++ b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/DatasetImpl.java
@@ -98,9 +98,8 @@ final class DatasetImpl implements Dataset {
             final Literal literal = (Literal) object;
             if (literal.getLanguageTag().isPresent()) {
                 return factory.createLiteral(literal.getLexicalForm(), literal.getLanguageTag().get());
-            } else {
-                return factory.createLiteral(literal.getLexicalForm(), (IRI) internallyMap(literal.getDatatype()));
             }
+            return factory.createLiteral(literal.getLexicalForm(), (IRI) internallyMap(literal.getDatatype()));
         } else {
             throw new IllegalArgumentException("Not a BlankNode, IRI or Literal: " + object);
         }
@@ -186,9 +185,8 @@ final class DatasetImpl implements Dataset {
         final String s = stream().limit(TO_STRING_MAX).map(Object::toString).collect(Collectors.joining("\n"));
         if (size() > TO_STRING_MAX) {
             return s + "\n# ... +" + (size() - TO_STRING_MAX) + " more";
-        } else {
-            return s;
         }
+        return s;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/commons-rdf/blob/9285480e/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
----------------------------------------------------------------------
diff --git a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
index 2c3bee4..92307ce 100644
--- a/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
+++ b/commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/GraphImpl.java
@@ -79,9 +79,8 @@ final class GraphImpl implements Graph {
             final Literal literal = (Literal) object;
             if (literal.getLanguageTag().isPresent()) {
                 return factory.createLiteral(literal.getLexicalForm(), literal.getLanguageTag().get());
-            } else {
-                return factory.createLiteral(literal.getLexicalForm(), (IRI) internallyMap(literal.getDatatype()));
             }
+            return factory.createLiteral(literal.getLexicalForm(), (IRI) internallyMap(literal.getDatatype()));
         } else {
             throw new IllegalArgumentException("RDFTerm was neither a BlankNode, IRI nor
Literal: " + object);
         }
@@ -96,9 +95,8 @@ final class GraphImpl implements Graph {
         if (newSubject == triple.getSubject() && newPredicate == triple.getPredicate()
                 && newObject == triple.getObject()) {
             return triple;
-        } else {
-            return factory.createTriple(newSubject, newPredicate, newObject);
         }
+        return factory.createTriple(newSubject, newPredicate, newObject);
     }
 
     @Override
@@ -171,9 +169,8 @@ final class GraphImpl implements Graph {
         final String s = stream().limit(TO_STRING_MAX).map(Object::toString).collect(Collectors.joining("\n"));
         if (size() > TO_STRING_MAX) {
             return s + "\n# ... +" + (size() - TO_STRING_MAX) + " more";
-        } else {
-            return s;
         }
+        return s;
     }
 
 }


Mime
View raw message