Skip to content

Commit 3d4ac5d

Browse files
committed
Rename ParamsMapper -> ParametersMapped and ParamMapper -> ParametersMapper
1 parent 2effe5a commit 3d4ac5d

File tree

15 files changed

+62
-66
lines changed

15 files changed

+62
-66
lines changed

vertx-sql-client-template/src/main/asciidoc/index.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ A Vert.x data object is a simple Java bean class annotated with the `@DataObject
199199

200200
=== Code generation
201201

202-
Any data object annotated by {@link io.vertx.sqlclient.template.annotations.RowMapped} or {@link io.vertx.sqlclient.template.annotations.ParamsMapped}
202+
Any data object annotated by {@link io.vertx.sqlclient.template.annotations.RowMapped} or {@link io.vertx.sqlclient.template.annotations.ParametersMapped}
203203
will trigger the generation of a corresponding mapper class.
204204

205205
The _codegen_ annotation processor generates these classes at compilation time. It is a feature of the Java
@@ -284,7 +284,7 @@ The generated mapper can be used to perform row mapping like explained in <<row_
284284

285285
=== Parameters mapping
286286

287-
You can generate a parameters mapper by annotating your data object by {@link io.vertx.sqlclient.template.annotations.ParamsMapped}.
287+
You can generate a parameters mapper by annotating your data object by {@link io.vertx.sqlclient.template.annotations.ParametersMapped}.
288288

289289
[source,$lang]
290290
----
@@ -294,7 +294,7 @@ You can generate a parameters mapper by annotating your data object by {@link io
294294
By default each parameter is bound after the data object properties, e.g the `userName` property binds to
295295
the `userName` parameter.
296296

297-
You can use custom names thanks to the {@link io.vertx.sqlclient.template.annotations.TemplateParam}
297+
You can use custom names thanks to the {@link io.vertx.sqlclient.template.annotations.TemplateParameter}
298298
annotation.
299299

300300
[source,$lang]
@@ -320,9 +320,9 @@ Usually Java enum types are mapped to string / numbers and possibly custom datab
320320
=== Naming format
321321

322322
The default template use the same case for parameters and columns. You can override the default names in the `Column`
323-
and `TemplateParam` annotations and use the formatting you like.
323+
and `TemplateParameter` annotations and use the formatting you like.
324324

325-
You can also configure a specific formatting case of a mapper in the `RowMapped` and `ParamsMapped` annotations:
325+
You can also configure a specific formatting case of a mapper in the `RowMapped` and `ParametersMapped` annotations:
326326

327327
[source,$lang]
328328
----

vertx-sql-client-template/src/main/java/examples/TemplateExamples.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
import io.vertx.sqlclient.SqlClient;
99
import io.vertx.sqlclient.template.SqlTemplate;
1010
import io.vertx.sqlclient.template.annotations.Column;
11-
import io.vertx.sqlclient.template.annotations.ParamsMapped;
11+
import io.vertx.sqlclient.template.annotations.ParametersMapped;
1212
import io.vertx.sqlclient.template.annotations.RowMapped;
13-
import io.vertx.sqlclient.template.annotations.TemplateParam;
13+
import io.vertx.sqlclient.template.annotations.TemplateParameter;
1414

15-
import java.util.Arrays;
1615
import java.util.Collections;
1716
import java.util.HashMap;
1817
import java.util.List;
@@ -29,11 +28,11 @@ static class User {
2928
}
3029

3130
public void queryExample(SqlClient client) {
32-
Map<String, Object> params = Collections.singletonMap("id", 1);
31+
Map<String, Object> parameters = Collections.singletonMap("id", 1);
3332

3433
SqlTemplate
3534
.forQuery(client, "SELECT * FROM users WHERE id=${id}")
36-
.execute(params)
35+
.execute(parameters)
3736
.onSuccess(users -> {
3837
users.forEach(row -> {
3938
System.out.println(row.getString("first_name") + " " + row.getString("last_name"));
@@ -42,14 +41,14 @@ public void queryExample(SqlClient client) {
4241
}
4342

4443
public void insertExample(SqlClient client) {
45-
Map<String, Object> params = new HashMap<>();
46-
params.put("id", 1);
47-
params.put("firstName", "Dale");
48-
params.put("lastName", "Cooper");
44+
Map<String, Object> parameters = new HashMap<>();
45+
parameters.put("id", 1);
46+
parameters.put("firstName", "Dale");
47+
parameters.put("lastName", "Cooper");
4948

5049
SqlTemplate
5150
.forUpdate(client, "INSERT INTO users VALUES (${id},${firstName},${lastName})")
52-
.execute(params)
51+
.execute(parameters)
5352
.onSuccess(v -> {
5453
System.out.println("Successful update");
5554
});
@@ -85,21 +84,21 @@ public void bindingRowWithCustomFunction(SqlClient client) {
8584
});
8685
}
8786

88-
private static final Function<User, Map<String, Object>> PARAMS_USER_MAPPER = user -> {
89-
Map<String, Object> params = new HashMap<>();
90-
params.put("id", user.id);
91-
params.put("firstName", user.firstName);
92-
params.put("lastName", user.lastName);
93-
return params;
87+
private static final Function<User, Map<String, Object>> PARAMETERS_USER_MAPPER = user -> {
88+
Map<String, Object> parameters = new HashMap<>();
89+
parameters.put("id", user.id);
90+
parameters.put("firstName", user.firstName);
91+
parameters.put("lastName", user.lastName);
92+
return parameters;
9493
};
9594

9695
public void paramsUserMapper() {
97-
Function<User, Map<String, Object>> PARAMS_USER_MAPPER = user -> {
98-
Map<String, Object> params = new HashMap<>();
99-
params.put("id", user.id);
100-
params.put("firstName", user.firstName);
101-
params.put("lastName", user.lastName);
102-
return params;
96+
Function<User, Map<String, Object>> PARAMETERS_USER_MAPPER = user -> {
97+
Map<String, Object> parameters = new HashMap<>();
98+
parameters.put("id", user.id);
99+
parameters.put("firstName", user.firstName);
100+
parameters.put("lastName", user.lastName);
101+
return parameters;
103102
};
104103
}
105104

@@ -111,7 +110,7 @@ public void bindingParamsWithCustomFunction(SqlClient client) {
111110

112111
SqlTemplate
113112
.forUpdate(client, "INSERT INTO users VALUES (${id},${firstName},${lastName})")
114-
.mapFrom(PARAMS_USER_MAPPER)
113+
.mapFrom(PARAMETERS_USER_MAPPER)
115114
.execute(user)
116115
.onSuccess(res -> {
117116
System.out.println("User inserted");
@@ -121,7 +120,7 @@ public void bindingParamsWithCustomFunction(SqlClient client) {
121120
public void batchBindingParamsWithCustomFunction(SqlClient client, List<User> users) {
122121
SqlTemplate
123122
.forUpdate(client, "INSERT INTO users VALUES (${id},${firstName},${lastName})")
124-
.mapFrom(PARAMS_USER_MAPPER)
123+
.mapFrom(PARAMETERS_USER_MAPPER)
125124
.executeBatch(users)
126125
.onSuccess(res -> {
127126
System.out.println("Users inserted");
@@ -273,7 +272,7 @@ public void bindingRowWithRowMapper(SqlClient client) {
273272

274273
public void paramsMappedDataObject() {
275274
@DataObject
276-
@ParamsMapped
275+
@ParametersMapped
277276
class UserDataObject {
278277

279278
private long id;
@@ -308,13 +307,13 @@ public void setLastName(String lastName) {
308307

309308
public void paramsMappedDataObjectOverrideName() {
310309
@DataObject
311-
@ParamsMapped
310+
@ParametersMapped
312311
class UserDataObject {
313312

314313
private long id;
315-
@TemplateParam(name = "first_name")
314+
@TemplateParameter(name = "first_name")
316315
private String firstName;
317-
@TemplateParam(name = "last_name")
316+
@TemplateParameter(name = "last_name")
318317
private String lastName;
319318

320319
public long getId() {
@@ -360,7 +359,7 @@ public void bindingParamsWithParamsMapper(SqlClient client) {
360359
public void customFormatter() {
361360
@DataObject
362361
@RowMapped(formatter = SnakeCase.class)
363-
@ParamsMapped(formatter = QualifiedCase.class)
362+
@ParametersMapped(formatter = QualifiedCase.class)
364363
class UserDataObject {
365364
// ...
366365
}

vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/annotations/ParamsMapped.java renamed to vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/annotations/ParametersMapped.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
@Retention(RetentionPolicy.RUNTIME)
1515
@Target({ElementType.TYPE})
16-
public @interface ParamsMapped {
16+
public @interface ParametersMapped {
1717

1818
/**
1919
* @return the parameter name formatter, default maps to lower camel case.

vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/annotations/TemplateParam.java renamed to vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/annotations/TemplateParameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
@Retention(RetentionPolicy.RUNTIME)
1212
@Target({ElementType.METHOD, ElementType.FIELD})
13-
public @interface TemplateParam {
13+
public @interface TemplateParameter {
1414

1515
/**
1616
* @return the template parameter name

vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/generator/MapperGenLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class MapperGenLoader implements GeneratorLoader {
1010

1111
@Override
1212
public Stream<Generator<?>> loadGenerators(ProcessingEnvironment processingEnv) {
13-
return Stream.of(new RowMapperGen(), new ParamMapperGen());
13+
return Stream.of(new RowMapperGen(), new ParametersMapperGen());
1414
}
1515
}

vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/generator/ParamMapperGen.java renamed to vertx-sql-client-template/src/main/java/io/vertx/sqlclient/template/generator/ParametersMapperGen.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
import io.vertx.codegen.DataObjectModel;
44
import io.vertx.codegen.annotations.DataObject;
55
import io.vertx.codegen.type.AnnotationValueInfo;
6-
import io.vertx.sqlclient.template.annotations.ParamsMapped;
7-
import io.vertx.sqlclient.template.annotations.RowMapped;
8-
import io.vertx.sqlclient.template.annotations.TemplateParam;
6+
import io.vertx.sqlclient.template.annotations.ParametersMapped;
7+
import io.vertx.sqlclient.template.annotations.TemplateParameter;
98

109
import java.io.PrintWriter;
1110
import java.lang.annotation.Annotation;
@@ -16,9 +15,9 @@
1615
/**
1716
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a>
1817
*/
19-
public class ParamMapperGen extends MapperGenBase {
18+
public class ParametersMapperGen extends MapperGenBase {
2019

21-
public ParamMapperGen() {
20+
public ParametersMapperGen() {
2221
kinds = Collections.singleton("dataObject");
2322
name = "data_object_mappers";
2423
}
@@ -35,14 +34,14 @@ protected String genFunctionExtends(DataObjectModel model) {
3534

3635
@Override
3736
protected String genSimpleName(DataObjectModel model) {
38-
return model.getType().getSimpleName() + "ParamMapper";
37+
return model.getType().getSimpleName() + "ParametersMapper";
3938
}
4039

4140
@Override
4241
protected Optional<AnnotationValueInfo> getAnnotation(DataObjectModel model) {
4342
return model
4443
.getAnnotations()
45-
.stream().filter(ann -> ann.getName().equals(ParamsMapped.class.getName()))
44+
.stream().filter(ann -> ann.getName().equals(ParametersMapped.class.getName()))
4645
.findFirst();
4746
}
4847

@@ -64,7 +63,7 @@ private void genToParams(String visibility, DataObjectModel model, PrintWriter w
6463
.stream()
6564
.filter(prop -> PK.contains(prop.getKind()))
6665
.forEach(pi -> {
67-
String templateParamName = getMappingName(pi, TemplateParam.class.getName());
66+
String templateParamName = getMappingName(pi, TemplateParameter.class.getName());
6867
if (templateParamName != null) {
6968
writer.print(" params.put(\"" + templateParamName + "\", obj." + pi.getGetterMethod() + "());\n");
7069
}

vertx-sql-client-template/src/test/generated/io/vertx/sqlclient/template/MySQLDataObjectParamMapper.java renamed to vertx-sql-client-template/src/test/generated/io/vertx/sqlclient/template/MySQLDataObjectParametersMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Mapper for {@link MySQLDataObject}.
55
* NOTE: This class has been automatically generated from the {@link MySQLDataObject} original class using Vert.x codegen.
66
*/
7-
public class MySQLDataObjectParamMapper implements java.util.function.Function<MySQLDataObject, java.util.Map<String, Object>> {
7+
public class MySQLDataObjectParametersMapper implements java.util.function.Function<MySQLDataObject, java.util.Map<String, Object>> {
88

9-
public static final java.util.function.Function<MySQLDataObject, java.util.Map<String, Object>> INSTANCE = new MySQLDataObjectParamMapper();
9+
public static final java.util.function.Function<MySQLDataObject, java.util.Map<String, Object>> INSTANCE = new MySQLDataObjectParametersMapper();
1010

1111
public java.util.Map<String, Object> apply(MySQLDataObject obj) {
1212
java.util.Map<String, Object> params = new java.util.HashMap<>();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Mapper for {@link PostgreSQLDataObject}.
55
* NOTE: This class has been automatically generated from the {@link PostgreSQLDataObject} original class using Vert.x codegen.
66
*/
7-
public class PostgreSQLDataObjectParamMapper implements java.util.function.Function<PostgreSQLDataObject, java.util.Map<String, Object>> {
7+
public class PostgreSQLDataObjectParametersMapper implements java.util.function.Function<PostgreSQLDataObject, java.util.Map<String, Object>> {
88

9-
public static final java.util.function.Function<PostgreSQLDataObject, java.util.Map<String, Object>> INSTANCE = new PostgreSQLDataObjectParamMapper();
9+
public static final java.util.function.Function<PostgreSQLDataObject, java.util.Map<String, Object>> INSTANCE = new PostgreSQLDataObjectParametersMapper();
1010

1111
public java.util.Map<String, Object> apply(PostgreSQLDataObject obj) {
1212
java.util.Map<String, Object> params = new java.util.HashMap<>();

vertx-sql-client-template/src/test/generated/io/vertx/sqlclient/template/TestDataObjectParamMapper.java renamed to vertx-sql-client-template/src/test/generated/io/vertx/sqlclient/template/TestDataObjectParametersMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Mapper for {@link TestDataObject}.
55
* NOTE: This class has been automatically generated from the {@link TestDataObject} original class using Vert.x codegen.
66
*/
7-
public class TestDataObjectParamMapper implements java.util.function.Function<TestDataObject, java.util.Map<String, Object>> {
7+
public class TestDataObjectParametersMapper implements java.util.function.Function<TestDataObject, java.util.Map<String, Object>> {
88

9-
public static final java.util.function.Function<TestDataObject, java.util.Map<String, Object>> INSTANCE = new TestDataObjectParamMapper();
9+
public static final java.util.function.Function<TestDataObject, java.util.Map<String, Object>> INSTANCE = new TestDataObjectParametersMapper();
1010

1111
public java.util.Map<String, Object> apply(TestDataObject obj) {
1212
java.util.Map<String, Object> params = new java.util.HashMap<>();

vertx-sql-client-template/src/test/java/io/vertx/sqlclient/template/DataObjectParamsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private void testGet(TestContext ctx, String sqlType, String paramName, TestData
6969
ctx,
7070
sqlType,
7171
Function.identity(),
72-
TestDataObjectParamMapper.INSTANCE,
72+
TestDataObjectParametersMapper.INSTANCE,
7373
paramName,
7474
obj,
7575
expected,

0 commit comments

Comments
 (0)