Skip to content

Commit

Permalink
Adapt api
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Oct 13, 2024
1 parent fdb62fa commit 60a8726
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/main/java/org/itsallcode/jdbc/BatchInsertBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,24 @@ public class BatchInsertBuilder<T> {
* @return {@code this} for fluent programming
*/
@SuppressWarnings("java:S3242") // Using List instead of Collection to preserve column order
public BatchInsertBuilder<T> into(final String tableName, final List<String> columnNames) {
this.sql = createInsertStatement(Identifier.simple(tableName),
columnNames.stream().map(Identifier::simple).toList());
public BatchInsertBuilder<T> into(final Identifier tableName, final List<Identifier> columnNames) {
this.sql = createInsertStatement(tableName, columnNames);
return this;
}

/**
* Define table and column names used for generating the {@code INSERT}
* statement.
*
* @param tableName table name
* @param columnNames column names
* @return {@code this} for fluent programming
*/
@SuppressWarnings("java:S3242") // Using List instead of Collection to preserve column order
public BatchInsertBuilder<T> into(final String tableName, final List<String> columnNames) {
return into(Identifier.simple(tableName), columnNames.stream().map(Identifier::simple).toList());
}

/**
* Define {@link Stream} of rows to insert.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* A qualified identifier, e.g. table name and schema name.
*/
record QualifiedIdentifier(List<Identifier> id) implements Identifier {
public record QualifiedIdentifier(List<Identifier> id) implements Identifier {

/**
* Create a new qualified identifier.
Expand All @@ -21,6 +21,16 @@ public static Identifier of(final Identifier... ids) {
return new QualifiedIdentifier(asList(ids));
}

/**
* Create a new qualified identifier.
*
* @param ids the simple IDs
* @return a new instance
*/
public static Identifier of(final String... ids) {
return of(asList(ids).stream().map(Identifier::simple).toArray(Identifier[]::new));
}

@Override
public String toString() {
return quote();
Expand Down

0 comments on commit 60a8726

Please sign in to comment.