Skip to content
Permalink
Browse files
No need to nest in else clause.
  • Loading branch information
garydgregory committed Oct 30, 2017
1 parent d77f8dd commit 9285480e74acd8bf56545c454eb8e1d41f2aa42f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
@@ -84,9 +84,8 @@ public Stream<? extends Quad> stream(final Optional<BlankNodeOrIRI> graphName, f
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 @@ public Graph getGraph() {
public Optional<Graph> getGraph(final BlankNodeOrIRI graphName) {
if (graphName == null) {
return Optional.of(getGraph());
} else {
return Optional.empty();
}
return Optional.empty();
}

@Override
@@ -78,8 +78,7 @@ public Stream<? extends Triple> stream(final BlankNodeOrIRI subject, final IRI p
filteredStreamCalled = true;
if (contains(subject, predicate, object)) {
return Stream.of(new DummyTriple());
} else {
return Stream.empty();
}
return Stream.empty();
}
}
@@ -280,12 +280,11 @@ String asJsonLdString(final BlankNodeOrIRI blankNodeOrIRI) {
// 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 @@ JsonLdTerm asRDFTerm(final Node node, final String blankNodePrefix) {
// 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);
}
@@ -80,9 +80,8 @@ private boolean isValidBlankNodeLabel(final String id) {
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
@@ -100,11 +100,10 @@ public long size() {
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
@@ -91,10 +91,9 @@ public long size() {
try (RepositoryConnection conn = getRepositoryConnection()) {
return conn.size();
}
} else {
try (Stream<RDF4JTriple> stream = stream()) {
return stream.count();
}
}
try (Stream<RDF4JTriple> stream = stream()) {
return stream.count();
}
}

@@ -98,9 +98,8 @@ private <T extends RDFTerm> RDFTerm internallyMap(final T object) {
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 @@ public String toString() {
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
@@ -79,9 +79,8 @@ private <T extends RDFTerm> RDFTerm internallyMap(final T object) {
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 @@ private Triple internallyMap(final Triple triple) {
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 @@ public String toString() {
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;
}

}

0 comments on commit 9285480

Please sign in to comment.