Skip to content

Commit 766e564

Browse files
committed
Code improvements.
Signed-off-by: Franz Wilhelmstötter <franz.wilhelmstoetter@gmail.com>
1 parent dfcbcfc commit 766e564

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
/**
3838
* This interface is responsible for <em>deconstructing</em> a given record, of
3939
* type {@code T}, to a DB-<em>row</em> ({@link ParamValues}).
40-
*
4140
* {@snippet lang="java":
4241
* final Dctor<Book> dctor = Dctor.of(
4342
* Dctor.field("title", Book::title),

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private Records() {
107107
* @throws IllegalArgumentException if there are duplicate fields defined
108108
*/
109109
public static <T extends Record> Dctor<T> dctor(
110-
final Class<T> type,
110+
final Class<? extends T> type,
111111
final Function<? super RecordComponent, String> toColumnName,
112112
final List<? extends Dctor.Field<? super T>> fields
113113
) {
@@ -187,7 +187,7 @@ private static <T extends Record> Dctor.Field<? super T> toFiled(
187187
*/
188188
@SafeVarargs
189189
public static <T extends Record> Dctor<T> dctor(
190-
final Class<T> type,
190+
final Class<? extends T> type,
191191
final Function<? super RecordComponent, String> toColumnName,
192192
final Dctor.Field<? super T>... fields
193193
) {
@@ -233,7 +233,7 @@ public static <T extends Record> Dctor<T> dctor(
233233
*/
234234
@SafeVarargs
235235
public static <T extends Record> Dctor<T> dctor(
236-
final Class<T> type,
236+
final Class<? extends T> type,
237237
final Dctor.Field<? super T>... fields
238238
) {
239239
return dctor(type, Records::toSnakeCase, List.of(fields));
@@ -343,7 +343,7 @@ public static String toSnakeCase(final String name) {
343343
* @throws NullPointerException if one of the arguments is {@code null}
344344
*/
345345
public static <T extends Record> RowParser<T> parser(
346-
final Class<T> type,
346+
final Class<? extends T> type,
347347
final Function<? super RecordComponent, String> toColumnName,
348348
final Function<? super RecordComponent, ? extends RowParser<?>> fields
349349
) {
@@ -357,7 +357,7 @@ public static <T extends Record> RowParser<T> parser(
357357
.map(toColumnName)
358358
.toArray(String[]::new);
359359

360-
final Constructor<T> ctor = ctor(type);
360+
final var ctor = ctor(type);
361361

362362
return (row, conn) -> {
363363
final Object[] values = new Object[components.length];
@@ -402,7 +402,7 @@ public static <T extends Record> RowParser<T> parser(
402402
* @throws NullPointerException if one of the arguments is {@code null}
403403
*/
404404
public static <T extends Record> RowParser<T> parser(
405-
final Class<T> type,
405+
final Class<? extends T> type,
406406
final Map<? super String, String> toColumnName,
407407
final Map<? super String, ? extends RowParser<?>> fields
408408
) {
@@ -442,7 +442,7 @@ public static <T extends Record> RowParser<T> parser(
442442
* @throws NullPointerException if one of the arguments is {@code null}
443443
*/
444444
public static <T extends Record> RowParser<T> parserWithColumnNames(
445-
final Class<T> type,
445+
final Class<? extends T> type,
446446
final Function<? super RecordComponent, String> toColumnName
447447
) {
448448
return parser(type, toColumnName, component -> null);
@@ -470,7 +470,7 @@ public static <T extends Record> RowParser<T> parserWithColumnNames(
470470
* @throws NullPointerException if one of the arguments is {@code null}
471471
*/
472472
public static <T extends Record> RowParser<T> parserWithColumnNames(
473-
final Class<T> type,
473+
final Class<? extends T> type,
474474
final Map<? super String, String> toColumnName
475475
) {
476476
return parser(type, toColumnName, Map.of());
@@ -502,7 +502,7 @@ public static <T extends Record> RowParser<T> parserWithColumnNames(
502502
* @throws NullPointerException if one of the arguments is {@code null}
503503
*/
504504
public static <T extends Record> RowParser<T> parserWithFields(
505-
final Class<T> type,
505+
final Class<? extends T> type,
506506
final Function<? super RecordComponent, ? extends RowParser<?>> fields
507507
) {
508508
return parser(type, Records::toSnakeCase, fields);
@@ -529,7 +529,7 @@ public static <T extends Record> RowParser<T> parserWithFields(
529529
* @throws NullPointerException if one of the arguments is {@code null}
530530
*/
531531
public static <T extends Record> RowParser<T> parserWithFields(
532-
final Class<T> type,
532+
final Class<? extends T> type,
533533
final Map<? super String, ? extends RowParser<?>> fields
534534
) {
535535
return parser(type, Records::toSnakeCase, cmp -> fields.get(cmp.getName()));
@@ -550,7 +550,7 @@ public static <T extends Record> RowParser<T> parserWithFields(
550550
* @return a new row-parser for the given record {@code type}
551551
* @throws NullPointerException if one of the arguments is {@code null}
552552
*/
553-
public static <T extends Record> RowParser<T> parser(final Class<T> type) {
553+
public static <T extends Record> RowParser<T> parser(final Class<? extends T> type) {
554554
return parser(type, Records::toSnakeCase, component -> null);
555555
}
556556

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class Reflections {
3636
private Reflections() {
3737
}
3838

39-
static <T extends Record> Constructor<T> ctor(final Class<T> type) {
39+
static <T extends Record> Constructor<? extends T> ctor(final Class<? extends T> type) {
4040
final Class<?>[] columnTypes = Stream.of(type.getRecordComponents())
4141
.map(RecordComponent::getType)
4242
.toArray(Class<?>[]::new);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ default ResultSetParser<Optional<T>> singleOpt() {
247247
* @throws NullPointerException if the given {@code factory} is {@code null}
248248
*/
249249
default <C extends Collection<T>>
250-
ResultSetParser<C> collection(final Supplier<C> factory) {
250+
ResultSetParser<C> collection(final Supplier<? extends C> factory) {
251251
return collection(factory, Function.identity());
252252
}
253253

@@ -269,7 +269,7 @@ default ResultSetParser<List<T>> list() {
269269
*
270270
* @return a new parser witch parses a whole selection result
271271
*/
272-
default ResultSetParser<T[]> array(final Class<T> type) {
272+
default ResultSetParser<T[]> array(final Class<? extends T> type) {
273273
return (rs, conn) -> list().parse(rs, conn).toArray(length -> {
274274
@SuppressWarnings("unchecked")
275275
final var array = (T[])Array.newInstance(type, length);
@@ -279,7 +279,7 @@ default ResultSetParser<T[]> array(final Class<T> type) {
279279

280280
private <C1 extends Collection<T>, C2 extends Collection<T>>
281281
ResultSetParser<C2> collection(
282-
final Supplier<C1> factory,
282+
final Supplier<? extends C1> factory,
283283
final Function<? super C1, ? extends C2> mapper
284284
) {
285285
requireNonNull(factory);
@@ -461,7 +461,7 @@ static <A, B, T> RowParser<T> compose(
461461
* Returns a parser for a scalar not-null value.
462462
* {@snippet lang="java":
463463
* final String name = Query.of("SELECT name FROM person WHERE id = :id")
464-
* .on(value("id", 23))
464+
* .on(Param.value("id", 23))
465465
* .as(scalar(String.class).single(), conn);
466466
* }
467467
*
@@ -473,15 +473,15 @@ static <A, B, T> RowParser<T> compose(
473473
* @return a parser for a scalar not-null value
474474
* @throws NullPointerException if the give {@code type} is {@code null}
475475
*/
476-
static <T> RowParser<T> scalar(final Class<T> type) {
476+
static <T> RowParser<T> scalar(final Class<? extends T> type) {
477477
return scalar(1, type);
478478
}
479479

480480
/**
481481
* Returns a parser for a scalar not-null value.
482482
* {@snippet lang="java":
483483
* final String name = Query.of("SELECT id, name FROM person WHERE id = :id")
484-
* .on(value("id", 23))
484+
* .on(Param.value("id", 23))
485485
* .as(scalar(2, String.class).single(), conn);
486486
* }
487487
*
@@ -496,15 +496,15 @@ static <T> RowParser<T> scalar(final Class<T> type) {
496496
* @return a parser for a scalar not-null value
497497
* @throws NullPointerException if the give {@code type} is {@code null}
498498
*/
499-
static <T> RowParser<T> scalar(final int index, final Class<T> type) {
499+
static <T> RowParser<T> scalar(final int index, final Class<? extends T> type) {
500500
return (row, conn) -> row.getObject(index, type);
501501
}
502502

503503
/**
504504
* Returns a parser for a scalar not-null value.
505505
* {@snippet lang="java":
506506
* final String name = Query.of("SELECT id, name FROM person WHERE id = :id")
507-
* .on(value("id", 23))
507+
* .on(Param.value("id", 23))
508508
* .as(scalar("name", String.class).single(), conn);
509509
* }
510510
*
@@ -519,7 +519,7 @@ static <T> RowParser<T> scalar(final int index, final Class<T> type) {
519519
* @return a parser for a scalar not-null value
520520
* @throws NullPointerException if the give {@code type} is {@code null}
521521
*/
522-
static <T> RowParser<T> scalar(final String name, final Class<T> type) {
522+
static <T> RowParser<T> scalar(final String name, final Class<? extends T> type) {
523523
return (row, conn) -> row.getObject(name, type);
524524
}
525525

@@ -887,7 +887,7 @@ static RowParser<String> csvLine() {
887887
* @param <T> the record type
888888
* @throws NullPointerException if the give {@code type} is {@code null}
889889
*/
890-
static <T extends Record> RowParser<T> record(final Class<T> type) {
890+
static <T extends Record> RowParser<T> record(final Class<? extends T> type) {
891891
return Records.parser(type);
892892
}
893893

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
/**
2323
* This class combines a record, stored in the DB, with its primary key.
2424
*
25-
* @since 2.1
26-
*
2725
* @param <K> the key type
2826
* @param <T> the record type, stored in the DB
2927
* @param id the primary key

0 commit comments

Comments
 (0)