Skip to content

Commit 792a092

Browse files
committed
#67: Mark 'ResultSetParser::csvLine' method as deprecated.
The method has been renamed to 'ResultSetParser::csv'. Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com>
1 parent 3db7d00 commit 792a092

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

facilejdbc/src/main/java/io/jenetics/facilejdbc/Param.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@
4242
* );
4343
* }
4444
* <p>
45+
* <b>Creating (lazy) single-valued parameters</b>
46+
* {@snippet lang="java":
47+
* INSERT_QUERY.on(
48+
* Param.lazyValue("inserted_at", Instant::now),
49+
* Param.value("forename", "Werner"),
50+
* Param.value("email", "some.email@gmail.com")
51+
* );
52+
* }
53+
* <p>
4554
* <b>Creating multi-valued parameters</b>
4655
* {@snippet lang="java":
4756
* var query = Query.of("SELECT * FROM table WHERE id = IN(:ids);")

facilejdbc/src/main/java/io/jenetics/facilejdbc/ResultSetParser.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,37 @@ T parse(final ResultSet rs, final Connection conn)
6868
/**
6969
* Return a {@link ResultSet} parser, which converts the query result to a
7070
* CSV line.
71-
* {@snippet lang="java":
71+
* {@snippet lang = "java":
72+
* final var select = Query.of("SELECT * FROM book;");
73+
* final var csv = select.as(ResultSetParser.csv(), conn);
74+
* System.out.println(csv);
75+
*}
76+
* The CSV output will look like this:
77+
* <pre>
78+
* "ID","PUBLISHED_AT","TITLE","ISBN","PAGES"
79+
* "0","1987-02-04","Auf der Suche nach der verlorenen Zeit","978-3518061756","5100"
80+
* "1","1945-01-04","Database Design for Mere Mortals","978-0321884497","654"
81+
* "2","1887-02-04","Der alte Mann und das Meer","B00JM4RD2S","142"
82+
* </pre>
83+
*
84+
* @since 3.0
85+
*
86+
* @see RowParser#csvLine()
87+
*
88+
* @return a CSV {@link ResultSet} parser
89+
*/
90+
static ResultSetParser<String> csv() {
91+
return CSV::string;
92+
}
93+
94+
/**
95+
* Return a {@link ResultSet} parser, which converts the query result to a
96+
* CSV line.
97+
* {@snippet lang = "java":
7298
* final var select = Query.of("SELECT * FROM book;");
7399
* final var csv = select.as(ResultSetParser.csvLine(), conn);
74100
* System.out.println(csv);
75-
* }
101+
*}
76102
* The CSV output will look like this:
77103
* <pre>
78104
* "ID","PUBLISHED_AT","TITLE","ISBN","PAGES"
@@ -87,6 +113,7 @@ T parse(final ResultSet rs, final Connection conn)
87113
*
88114
* @return a CSV {@link ResultSet} parser
89115
*/
116+
@Deprecated(since = "3.0", forRemoval = true)
90117
static ResultSetParser<String> csvLine() {
91118
return CSV::string;
92119
}

facilejdbc/src/main/java/io/jenetics/facilejdbc/RowParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ static RowParser<LocalDate> date(final int index) {
841841
*
842842
* @since 1.3
843843
*
844-
* @see ResultSetParser#csvLine()
844+
* @see ResultSetParser#csv()
845845
* @see #ofColumns(Function)
846846
*
847847
* @return a row parser which converts a DB row into a CSV row

facilejdbc/src/test/java/io/jenetics/facilejdbc/ParamsTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package io.jenetics.facilejdbc;
2121

2222
import java.sql.SQLException;
23+
import java.time.Instant;
2324
import java.util.List;
2425

2526
import org.testng.Assert;
@@ -39,7 +40,8 @@ public void set() throws SQLException {
3940
Param.value("name_2", "value_2"),
4041
Param.value("name_3", "value_3"),
4142
Param.value("name_4", "value_4"),
42-
Param.value("name_5", "value_5")
43+
Param.value("name_5", "value_5"),
44+
Param.lazyValue("inserted_at", Instant::now)
4345
));
4446

4547
params.set(List.of("name_2", "name_5", "name_1"), stmt);

facilejdbc/src/test/java/io/jenetics/facilejdbc/testdb/TestDbTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public void selectEmptyStream() throws SQLException {
221221
public void selectToCSV() throws SQLException {
222222
db.transaction().accept(conn -> {
223223
final var select = Query.of("SELECT * FROM book ORDER BY id;");
224-
final var csv = select.as(ResultSetParser.csvLine(), conn);
224+
final var csv = select.as(ResultSetParser.csv(), conn);
225225

226226
final var expected = """
227227
"ID","PUBLISHED_AT","TITLE","LANGUAGE","ISBN","PAGES"

0 commit comments

Comments
 (0)