commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [5/7] incubator-commonsrdf git commit: Add final modifier to local variables.
Date Fri, 11 Nov 2016 22:50:51 GMT
http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/56ddbdcf/simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
----------------------------------------------------------------------
diff --git a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
index 9576b4a..1157dc5 100644
--- a/simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
+++ b/simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java
@@ -219,7 +219,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
     public T clone() {
         try {
             return (T) super.clone();
-        } catch (CloneNotSupportedException e) {
+        } catch (final CloneNotSupportedException e) {
             throw new RuntimeException(e);
         }
     }
@@ -231,14 +231,14 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T rdfTermFactory(final RDF rdfTermFactory) {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.rdfTermFactory = Optional.ofNullable(rdfTermFactory);
         return c.asT();
     }
 
     @Override
     public T contentType(final RDFSyntax rdfSyntax) throws IllegalArgumentException {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.contentTypeSyntax = Optional.ofNullable(rdfSyntax);
         c.contentType = c.contentTypeSyntax.map(syntax -> syntax.mediaType);
         return c.asT();
@@ -246,7 +246,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T contentType(final String contentType) throws IllegalArgumentException {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.contentType = Optional.ofNullable(contentType);
         c.contentTypeSyntax = c.contentType.flatMap(RDFSyntax::byMediaType);
         return c.asT();
@@ -254,7 +254,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T base(final IRI base) {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.base = Optional.ofNullable(base);
         c.base.ifPresent(i -> checkIsAbsolute(i));
         return c.asT();
@@ -267,7 +267,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T source(final InputStream inputStream) {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.resetSource();
         c.sourceInputStream = Optional.ofNullable(inputStream);
         return c.asT();
@@ -275,7 +275,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T source(final Path file) {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.resetSource();
         c.sourceFile = Optional.ofNullable(file);
         return c.asT();
@@ -283,7 +283,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T source(final IRI iri) {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.resetSource();
         c.sourceIri = Optional.ofNullable(iri);
         c.sourceIri.ifPresent(i -> checkIsAbsolute(i));
@@ -292,7 +292,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T source(final String iri) throws IllegalArgumentException {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.resetSource();
         c.sourceIri = Optional.ofNullable(iri).map(internalRdfTermFactory::createIRI);
         c.sourceIri.ifPresent(i -> checkIsAbsolute(i));
@@ -428,7 +428,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
         // We'll make a clone of our current state which will be passed to
         // parseSynchronously()
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
 
         // Use a fresh SimpleRDF for each parse
         if (!c.rdfTermFactory.isPresent()) {
@@ -437,7 +437,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
         // sourceFile, but no base? Let's follow any symlinks and use
         // the file:/// URI
         if (c.sourceFile.isPresent() && !c.base.isPresent()) {
-            URI baseUri = c.sourceFile.get().toRealPath().toUri();
+            final URI baseUri = c.sourceFile.get().toRealPath().toUri();
             c.base = Optional.of(internalRdfTermFactory.createIRI(baseUri.toString()));
         }
 
@@ -502,12 +502,12 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
      *         {@link Optional#empty()} if the path has no extension
      */
     private static Optional<String> fileExtension(final Path path) {
-        Path fileName = path.getFileName();
+        final Path fileName = path.getFileName();
         if (fileName == null) {
             return Optional.empty();
         }
-        String filenameStr = fileName.toString();
-        int last = filenameStr.lastIndexOf(".");
+        final String filenameStr = fileName.toString();
+        final int last = filenameStr.lastIndexOf(".");
         if (last > -1) {
             return Optional.of(filenameStr.substring(last));
         }
@@ -541,7 +541,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
 
     @Override
     public T target(final Consumer<Quad> consumer) {
-        AbstractRDFParser<T> c = clone();
+        final AbstractRDFParser<T> c = clone();
         c.resetTarget();
         c.target = consumer;
         return c.asT();
@@ -550,6 +550,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
     @Override
     public T target(final Dataset dataset) {
         @SuppressWarnings({ "rawtypes", "unchecked" })
+        final
         AbstractRDFParser<T> c = (AbstractRDFParser) RDFParser.super.target(dataset);
         c.resetTarget();
         c.targetDataset = Optional.of(dataset);
@@ -559,6 +560,7 @@ public abstract class AbstractRDFParser<T extends AbstractRDFParser<T>>
implemen
     @Override
     public T target(final Graph graph) {
         @SuppressWarnings({ "rawtypes", "unchecked" }) // super calls our
+        final
                                                        // .clone()
         AbstractRDFParser<T> c = (AbstractRDFParser) RDFParser.super.target(graph);
         c.resetTarget();

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/56ddbdcf/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java
b/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java
index afb2129..02f37f4 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/DummyRDFParserBuilder.java
@@ -52,12 +52,12 @@ public class DummyRDFParserBuilder extends AbstractRDFParser<DummyRDFParserBuild
     @Override
     protected void parseSynchronusly() throws IOException, IllegalStateException, RDFParseException
{
         // From parseSynchronusly both of these are always present
-        RDF factory = getRdfTermFactory().get();
-        Consumer<Quad> t = getTarget();
+        final RDF factory = getRdfTermFactory().get();
+        final Consumer<Quad> t = getTarget();
 
         // well - each parsing is unique. This should hopefully
         // catch any accidental double parsing
-        IRI parsing = factory.createIRI("urn:uuid:" + UUID.randomUUID());
+        final IRI parsing = factory.createIRI("urn:uuid:" + UUID.randomUUID());
         t.accept(factory.createQuad(null, parsing, factory.createIRI("http://example.com/greeting"),
                 factory.createLiteral("Hello world")));
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/56ddbdcf/simple/src/test/java/org/apache/commons/rdf/simple/SimpleServiceLoaderTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleServiceLoaderTest.java
b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleServiceLoaderTest.java
index 4e37199..c79746e 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/SimpleServiceLoaderTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/SimpleServiceLoaderTest.java
@@ -29,8 +29,8 @@ public class SimpleServiceLoaderTest {
 
     @Test
     public void testServiceLoaderLookup() {
-        ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
-        for (RDF impl : loader) {
+        final ServiceLoader<RDF> loader = ServiceLoader.load(RDF.class);
+        for (final RDF impl : loader) {
             if (impl instanceof SimpleRDF) {
                 return; // yay
             }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/56ddbdcf/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
index add7d75..4f28af7 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
@@ -59,9 +59,9 @@ public class TestWritingGraph {
     public static void createGraph() throws Exception {
         factory = new SimpleRDF();
         graph = factory.createGraph();
-        IRI subject = factory.createIRI("subj");
-        IRI predicate = factory.createIRI("pred");
-        List<IRI> types = new ArrayList<>(Types.values());
+        final IRI subject = factory.createIRI("subj");
+        final IRI predicate = factory.createIRI("pred");
+        final List<IRI> types = new ArrayList<>(Types.values());
         // Ensure we don't try to create a literal with rdf:langString but
         // without a language tag
         types.remove(Types.RDF_LANGSTRING);
@@ -92,9 +92,9 @@ public class TestWritingGraph {
 
     @Test
     public void countQuery() {
-        IRI subject = factory.createIRI("subj");
-        IRI predicate = factory.createIRI("pred");
-        long count = graph.stream(subject, predicate, null).unordered().parallel().count();
+        final IRI subject = factory.createIRI("subj");
+        final IRI predicate = factory.createIRI("pred");
+        final long count = graph.stream(subject, predicate, null).unordered().parallel().count();
         // System.out.println("Counted - " + count);
         assertEquals(count, TRIPLES);
     }
@@ -106,45 +106,45 @@ public class TestWritingGraph {
 
     @Test
     public void writeGraphFromStream() throws Exception {
-        Path graphFile = Files.createTempFile("graph", ".nt");
+        final Path graphFile = Files.createTempFile("graph", ".nt");
         if (KEEP_FILES) {
             System.out.println("From stream: " + graphFile);
         } else {
             graphFile.toFile().deleteOnExit();
         }
 
-        Stream<CharSequence> stream = graph.stream().map(TestWritingGraph::tripleAsString);
+        final Stream<CharSequence> stream = graph.stream().map(TestWritingGraph::tripleAsString);
         Files.write(graphFile, stream::iterator, StandardCharsets.UTF_8);
     }
 
     @Test
     public void writeGraphFromStreamFiltered() throws Exception {
-        Path graphFile = Files.createTempFile("graph", ".nt");
+        final Path graphFile = Files.createTempFile("graph", ".nt");
         if (KEEP_FILES) {
             System.out.println("Filtered stream: " + graphFile);
         } else {
             graphFile.toFile().deleteOnExit();
         }
 
-        IRI subject = factory.createIRI("subj");
-        IRI predicate = factory.createIRI("pred");
-        Stream<CharSequence> stream = graph.stream(subject, predicate, null).map(TestWritingGraph::tripleAsString);
+        final IRI subject = factory.createIRI("subj");
+        final IRI predicate = factory.createIRI("pred");
+        final Stream<CharSequence> stream = graph.stream(subject, predicate, null).map(TestWritingGraph::tripleAsString);
         Files.write(graphFile, stream::iterator, StandardCharsets.UTF_8);
 
     }
 
     @Test
     public void writeGraphFromStreamFilteredNoMatches() throws Exception {
-        Path graphFile = Files.createTempFile("graph-empty-", ".nt");
+        final Path graphFile = Files.createTempFile("graph-empty-", ".nt");
         if (KEEP_FILES) {
             System.out.println("Filtered stream: " + graphFile);
         } else {
             graphFile.toFile().deleteOnExit();
         }
 
-        IRI subject = factory.createIRI("nonexistent");
-        IRI predicate = factory.createIRI("pred");
-        Stream<CharSequence> stream = graph.stream(subject, predicate, null).map(Object::toString);
+        final IRI subject = factory.createIRI("nonexistent");
+        final IRI predicate = factory.createIRI("pred");
+        final Stream<CharSequence> stream = graph.stream(subject, predicate, null).map(Object::toString);
         Files.write(graphFile, stream::iterator, StandardCharsets.UTF_8);
 
     }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/56ddbdcf/simple/src/test/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParserTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParserTest.java
b/simple/src/test/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParserTest.java
index 222d820..12061ed 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParserTest.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParserTest.java
@@ -81,18 +81,18 @@ public class AbstractRDFParserTest {
 
     private void checkGraph(final Graph g) throws Exception {
         assertTrue(g.size() > 0);
-        IRI greeting = factory.createIRI("http://example.com/greeting");
+        final IRI greeting = factory.createIRI("http://example.com/greeting");
         // Should only have parsed once!
         assertEquals(1, g.stream(null, greeting, null).count());
-        Triple triple = g.stream(null, greeting, null).findAny().get();
+        final Triple triple = g.stream(null, greeting, null).findAny().get();
         assertTrue(triple.getSubject() instanceof IRI);
-        IRI parsing = (IRI) triple.getSubject();
+        final IRI parsing = (IRI) triple.getSubject();
         assertTrue(parsing.getIRIString().startsWith("urn:uuid:"));
 
         assertEquals("http://example.com/greeting", triple.getPredicate().getIRIString());
 
         assertTrue(triple.getObject() instanceof Literal);
-        Literal literal = (Literal) triple.getObject();
+        final Literal literal = (Literal) triple.getObject();
         assertEquals("Hello world", literal.getLexicalForm());
         assertFalse(literal.getLanguageTag().isPresent());
         assertEquals(Types.XSD_STRING, literal.getDatatype());
@@ -108,8 +108,8 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseFile() throws Exception {
-        Graph g = factory.createGraph();
-        RDFParser parser = dummyParser.source(testNt).target(g);
+        final Graph g = factory.createGraph();
+        final RDFParser parser = dummyParser.source(testNt).target(g);
         parser.parse().get(5, TimeUnit.SECONDS);
         checkGraph(g);
         // FIXME: this could potentially break if the equivalent of /tmp
@@ -133,8 +133,8 @@ public class AbstractRDFParserTest {
     @Test
     public void parseBaseAndContentTypeNoSource() throws Exception {
         // Can set the other options, even without source()
-        IRI base = dummyParser.createRDFTermFactory().createIRI("http://www.example.org/test.rdf");
-        RDFParser parser = dummyParser.base(base).contentType(RDFSyntax.RDFXML);
+        final IRI base = dummyParser.createRDFTermFactory().createIRI("http://www.example.org/test.rdf");
+        final RDFParser parser = dummyParser.base(base).contentType(RDFSyntax.RDFXML);
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("No source has been set");
         // but .parse() should fail
@@ -145,7 +145,7 @@ public class AbstractRDFParserTest {
     public void parseFileMissing() throws Exception {
         Files.delete(testNt);
         // This should not fail yet
-        RDFParser parser = dummyParser.source(testNt);
+        final RDFParser parser = dummyParser.source(testNt);
         // but here:
         thrown.expect(IOException.class);
         parser.parse();
@@ -153,8 +153,8 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseFileContentType() throws Exception {
-        Graph g = factory.createGraph();
-        RDFParser parser = dummyParser.source(testNt).contentType(RDFSyntax.NTRIPLES).target(g);
+        final Graph g = factory.createGraph();
+        final RDFParser parser = dummyParser.source(testNt).contentType(RDFSyntax.NTRIPLES).target(g);
         parser.parse().get(5, TimeUnit.SECONDS);
         checkGraph(g);
         // FIXME: this could potentially break if the equivalent of /tmp
@@ -176,9 +176,9 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseInputStreamFailsIfBaseMissing() throws Exception {
-        InputStream inputStream = new ByteArrayInputStream(new byte[0]);
+        final InputStream inputStream = new ByteArrayInputStream(new byte[0]);
         // Should not fail at this point
-        RDFParser parser = dummyParser.source(inputStream);
+        final RDFParser parser = dummyParser.source(inputStream);
         // but here:
         thrown.expect(IllegalStateException.class);
         thrown.expectMessage("base iri required for inputstream source");
@@ -187,10 +187,10 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseInputStreamWithBase() throws Exception {
-        InputStream inputStream = new ByteArrayInputStream(new byte[0]);
-        IRI base = dummyParser.createRDFTermFactory().createIRI("http://www.example.org/test.rdf");
-        Graph g = factory.createGraph();
-        RDFParser parser = dummyParser.source(inputStream).base(base).target(g);
+        final InputStream inputStream = new ByteArrayInputStream(new byte[0]);
+        final IRI base = dummyParser.createRDFTermFactory().createIRI("http://www.example.org/test.rdf");
+        final Graph g = factory.createGraph();
+        final RDFParser parser = dummyParser.source(inputStream).base(base).target(g);
         parser.parse().get(5, TimeUnit.SECONDS);
         checkGraph(g);
         assertEquals("<http://www.example.org/test.rdf>", firstPredicate(g, "base"));
@@ -203,9 +203,9 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseInputStreamWithNQuads() throws Exception {
-        InputStream inputStream = new ByteArrayInputStream(new byte[0]);
-        Graph g = factory.createGraph();
-        RDFParser parser = dummyParser.source(inputStream).contentType(RDFSyntax.NQUADS).target(g);
+        final InputStream inputStream = new ByteArrayInputStream(new byte[0]);
+        final Graph g = factory.createGraph();
+        final RDFParser parser = dummyParser.source(inputStream).contentType(RDFSyntax.NQUADS).target(g);
         parser.parse().get(5, TimeUnit.SECONDS);
         checkGraph(g);
         assertNull(firstPredicate(g, "base"));
@@ -218,9 +218,9 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseIRI() throws Exception {
-        IRI iri = dummyParser.createRDFTermFactory().createIRI("http://www.example.net/test.ttl");
-        Graph g = factory.createGraph();
-        RDFParser parser = dummyParser.source(iri).target(g);
+        final IRI iri = dummyParser.createRDFTermFactory().createIRI("http://www.example.net/test.ttl");
+        final Graph g = factory.createGraph();
+        final RDFParser parser = dummyParser.source(iri).target(g);
         parser.parse().get(5, TimeUnit.SECONDS);
         checkGraph(g);
         assertEquals("<http://www.example.net/test.ttl>", firstPredicate(g, "source"));
@@ -236,9 +236,9 @@ public class AbstractRDFParserTest {
 
     @Test
     public void parseIRIBaseContentType() throws Exception {
-        IRI iri = dummyParser.createRDFTermFactory().createIRI("http://www.example.net/test.ttl");
-        Graph g = factory.createGraph();
-        RDFParser parser = dummyParser.source(iri).base(iri).contentType(RDFSyntax.TURTLE).target(g);
+        final IRI iri = dummyParser.createRDFTermFactory().createIRI("http://www.example.net/test.ttl");
+        final Graph g = factory.createGraph();
+        final RDFParser parser = dummyParser.source(iri).base(iri).contentType(RDFSyntax.TURTLE).target(g);
         parser.parse().get(5, TimeUnit.SECONDS);
         checkGraph(g);
         assertEquals("<http://www.example.net/test.ttl>", firstPredicate(g, "source"));


Mime
View raw message