sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ama...@apache.org
Subject [sis] 17/45: fix(SQLStore): fix checkstyle problems.
Date Tue, 12 Nov 2019 16:44:44 GMT
This is an automated email from the ASF dual-hosted git repository.

amanin pushed a commit to branch refactor/sql-store
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 4adea48372e354a350a3f487da36f6bac2c7d761
Author: Alexis Manin <amanin@apache.org>
AuthorDate: Thu Sep 26 14:42:10 2019 +0200

    fix(SQLStore): fix checkstyle problems.
---
 .../apache/sis/internal/sql/feature/Analyzer.java  |  6 +++---
 .../sis/internal/sql/feature/QueryFeatureSet.java  | 22 +++++++++----------
 .../sis/internal/sql/feature/ResultContext.java    | 25 ----------------------
 .../apache/sis/internal/sql/feature/StreamSQL.java |  4 ++--
 .../org/apache/sis/internal/sql/feature/Table.java |  4 ++--
 5 files changed, 18 insertions(+), 43 deletions(-)

diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Analyzer.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Analyzer.java
index ff5f0a7..6ac8fd7 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Analyzer.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Analyzer.java
@@ -415,7 +415,7 @@ final class Analyzer {
             } catch (DataStoreException e) {
                 throw new BackingStoreException(e);
             }
-            final AssociationRoleBuilder association = foreignTable == null?
+            final AssociationRoleBuilder association = foreignTable == null ?
                     target.addAssociation(foreignTypeName) : target.addAssociation(foreignTable.featureType);
             association.setName(r.propertyName);
         }
@@ -426,7 +426,7 @@ final class Analyzer {
         void fill(ResultSet source, final Feature target);
     }
 
-    private class TableMetadata implements SQLTypeSpecification {
+    private final class TableMetadata implements SQLTypeSpecification {
         final TableReference id;
         private final String tableEsc;
         private final String schemaEsc;
@@ -557,7 +557,7 @@ final class Analyzer {
         }
     }
 
-    private class QuerySpecification implements SQLTypeSpecification {
+    private final class QuerySpecification implements SQLTypeSpecification {
 
         final int total;
         final PreparedStatement source;
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
index 9d027a4..0565036 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/QueryFeatureSet.java
@@ -171,7 +171,7 @@ public class QueryFeatureSet extends AbstractFeatureSet {
         } catch (SQLException e) {
             try {
                 c.close();
-            } catch (RuntimeException|SQLException bis) {
+            } catch (RuntimeException | SQLException bis) {
                 e.addSuppressed(bis);
             }
             throw e;
@@ -189,7 +189,7 @@ public class QueryFeatureSet extends AbstractFeatureSet {
         return new StreamSQL(new QueryAdapter(queryBuilder), source);
     }
 
-    private class QueryAdapter implements QueryBuilder {
+    private final class QueryAdapter implements QueryBuilder {
 
         private final SQLBuilder source;
 
@@ -242,7 +242,7 @@ public class QueryFeatureSet extends AbstractFeatureSet {
         }
     }
 
-    private class PreparedQueryConnector implements Connector {
+    private final class PreparedQueryConnector implements Connector {
 
         final String sql;
         private long additionalOffset, additionalLimit;
@@ -264,8 +264,8 @@ public class QueryFeatureSet extends AbstractFeatureSet {
 
             return stream.onClose(() -> {
                 try (
-                        final AutoCloseable rc = result::close;
-                        final AutoCloseable sc = statement::close;
+                        AutoCloseable rc = result::close;
+                        AutoCloseable sc = statement::close;
                 ) {
                     // No-op. Using try with resource allows to manage closing of second
resource even if first one throws an error.
                 } catch (Exception e) {
@@ -280,19 +280,19 @@ public class QueryFeatureSet extends AbstractFeatureSet {
         }
     }
 
-    private class ResultSpliterator implements Spliterator<Feature> {
+    private final class ResultSpliterator implements Spliterator<Feature> {
 
-        final ResultContext result;
+        final ResultSet result;
 
         private ResultSpliterator(ResultSet result) {
-            this.result = new ResultContext(result);
+            this.result = result;
         }
 
         @Override
         public boolean tryAdvance(Consumer<? super Feature> action) {
             try {
-                if (result.source.next()) {
-                    final Feature f = adapter.read(result.source);
+                if (result.next()) {
+                    final Feature f = adapter.read(result);
                     action.accept(f);
                     return true;
                 } else return false;
@@ -310,7 +310,7 @@ public class QueryFeatureSet extends AbstractFeatureSet {
         public long estimateSize() {
             // TODO: economic size estimation ? A count query seems overkill for the aim
of this API. Howver, we could
             // analyze user query in search for a limit value.
-            return originLimit > 0? originLimit : Long.MAX_VALUE;
+            return originLimit > 0 ? originLimit : Long.MAX_VALUE;
         }
 
         @Override
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/ResultContext.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/ResultContext.java
deleted file mode 100644
index c7ef3df..0000000
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/ResultContext.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.apache.sis.internal.sql.feature;
-
-import java.sql.ResultSet;
-
-class ResultContext {
-    final ResultSet source;
-
-    ResultContext(ResultSet source) {
-        this.source = source;
-    }
-
-    Cell cell(int columnIndex, String propertyName) {
-        return new Cell(columnIndex, propertyName);
-    }
-
-    class Cell {
-        final int colIdx;
-        final String propertyName;
-
-        private Cell(int colIdx, String propertyName) {
-            this.colIdx = colIdx;
-            this.propertyName = propertyName;
-        }
-    }
-}
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
index 925da4e..890a9dd 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/StreamSQL.java
@@ -74,7 +74,7 @@ class StreamSQL extends StreamDecoration<Feature> {
 
     private Consumer<? super Feature> peekAction;
 
-    private long limit = 0, offset = 0;
+    private long limit, offset;
 
     private Consumer<SQLException> warningConsumer = e -> Logging.getLogger("sis.sql").log(Level.FINE,
"Cannot properly close a connection", e);
 
@@ -199,7 +199,7 @@ class StreamSQL extends StreamDecoration<Feature> {
                 })
                 .onClose(() -> closeRef(connectionRef, true));
         if (peekAction != null) featureStream = featureStream.peek(peekAction);
-        return parallel? featureStream : featureStream.parallel();
+        return parallel ? featureStream : featureStream.parallel();
     }
 
     /**
diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
index 27c96bc..80fc52b 100644
--- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
+++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Table.java
@@ -193,7 +193,7 @@ final class Table extends AbstractFeatureSet {
         this.featureType      = adapter.type;
         this.importedKeys     = toArray(specification.getImports());
         this.exportedKeys     = toArray(specification.getExports());
-        this.primaryKeyClass  = primaryKeys.length < 2? Object.class : Object[].class;
+        this.primaryKeyClass  = primaryKeys.length < 2 ? Object.class : Object[].class;
         this.hasGeometry      = specification.getPrimaryGeometryColumn().isPresent();
         this.attributes       = Collections.unmodifiableList(
                 specification.getColumns().stream()
@@ -219,7 +219,7 @@ final class Table extends AbstractFeatureSet {
 
         }
 
-        return remainingQuery? subset.subset(q) : subset;
+        return remainingQuery ? subset.subset(q) : subset;
     }
 
     /**


Mime
View raw message