diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatterCursor.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatterCursor.java index e5002e6e1e9..974eed339ea 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatterCursor.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/CliFormatterCursor.java @@ -22,9 +22,13 @@ import java.util.Objects; public class CliFormatterCursor implements Cursor { public static final String NAME = "f"; - private Cursor delegate; - private CliFormatter formatter; + private final Cursor delegate; + private final CliFormatter formatter; + /** + * If the newCursor is empty, returns an empty cursor. Otherwise, creates a new + * CliFormatterCursor that wraps the newCursor. + */ public static Cursor wrap(Cursor newCursor, CliFormatter formatter) { if (newCursor == EMPTY) { return EMPTY; @@ -32,7 +36,7 @@ public class CliFormatterCursor implements Cursor { return new CliFormatterCursor(newCursor, formatter); } - public CliFormatterCursor(Cursor delegate, CliFormatter formatter) { + private CliFormatterCursor(Cursor delegate, CliFormatter formatter) { this.delegate = delegate; this.formatter = formatter; } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/JdbcCursor.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/JdbcCursor.java index 31aefdaf939..f7cbadb2588 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/JdbcCursor.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/JdbcCursor.java @@ -24,10 +24,13 @@ import java.util.Objects; */ public class JdbcCursor implements Cursor { public static final String NAME = "j"; - private Cursor delegate; - private List types; - + private final Cursor delegate; + private final List types; + /** + * If the newCursor is empty, returns an empty cursor. Otherwise, creates a new + * CliFormatterCursor that wraps the newCursor. + */ public static Cursor wrap(Cursor newCursor, List types) { if (newCursor == EMPTY) { return EMPTY; @@ -35,7 +38,7 @@ public class JdbcCursor implements Cursor { return new JdbcCursor(newCursor, types); } - public JdbcCursor(Cursor delegate, List types) { + private JdbcCursor(Cursor delegate, List types) { this.delegate = delegate; this.types = types; } diff --git a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java index a9da155e646..bb51f5d5df0 100644 --- a/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java +++ b/sql/server/src/test/java/org/elasticsearch/xpack/sql/plugin/sql/action/SqlResponseTests.java @@ -44,11 +44,11 @@ public class SqlResponseTests extends AbstractStreamableTestCase { for (int i = 0; i < typeNum; i++) { types.add(randomFrom(JDBCType.values())); } - return new JdbcCursor(ScrollCursorTests.randomScrollCursor(), types); + return JdbcCursor.wrap(ScrollCursorTests.randomScrollCursor(), types); case 2: SqlResponse response = createRandomInstance(Cursor.EMPTY); if (response.columns() != null && response.rows() != null) { - return new CliFormatterCursor(ScrollCursorTests.randomScrollCursor(), new CliFormatter(response)); + return CliFormatterCursor.wrap(ScrollCursorTests.randomScrollCursor(), new CliFormatter(response)); } else { return ScrollCursorTests.randomScrollCursor(); }