Skip to content

Commit 2a6e796

Browse files
committed
refactor(RowMappers): move row mappers for the ru.mystamps.web.feature.participant package to this package.
Addressed to #927 No functional changes.
1 parent 07ba579 commit 2a6e796

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

src/main/java/ru/mystamps/web/feature/participant/JdbcParticipantDao.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.springframework.jdbc.support.KeyHolder;
2828
import ru.mystamps.web.common.EntityWithParentDto;
2929
import ru.mystamps.web.common.JdbcUtils;
30-
import ru.mystamps.web.support.jdbc.RowMappers;
3130

3231
import java.util.Collections;
3332
import java.util.HashMap;
@@ -93,15 +92,15 @@ public Integer add(AddParticipantDbDto participant) {
9392
public List<EntityWithParentDto> findBuyersWithParents() {
9493
return jdbcTemplate.query(
9594
findBuyersWithParentNamesSql,
96-
RowMappers::forEntityWithParentDto
95+
ru.mystamps.web.support.jdbc.RowMappers::forEntityWithParentDto
9796
);
9897
}
9998

10099
@Override
101100
public List<EntityWithParentDto> findSellersWithParents() {
102101
return jdbcTemplate.query(
103102
findSellersWithParentNamesSql,
104-
RowMappers::forEntityWithParentDto
103+
ru.mystamps.web.support.jdbc.RowMappers::forEntityWithParentDto
105104
);
106105
}
107106

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (C) 2009-2019 Slava Semushin <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.feature.participant;
19+
20+
import java.sql.ResultSet;
21+
import java.sql.SQLException;
22+
23+
final class RowMappers {
24+
25+
private RowMappers() {
26+
}
27+
28+
/* default */ static EntityWithIdDto forEntityWithIdDto(ResultSet rs, int unused)
29+
throws SQLException {
30+
31+
return new EntityWithIdDto(
32+
rs.getInt("id"),
33+
rs.getString("name")
34+
);
35+
}
36+
37+
}

src/main/java/ru/mystamps/web/support/jdbc/RowMappers.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import ru.mystamps.web.common.EntityWithParentDto;
2222
import ru.mystamps.web.common.JdbcUtils;
2323
import ru.mystamps.web.common.LinkEntityDto;
24-
import ru.mystamps.web.feature.participant.EntityWithIdDto;
2524
import ru.mystamps.web.feature.series.PurchaseAndSaleDto;
2625
import ru.mystamps.web.feature.series.SeriesFullInfoDto;
2726
import ru.mystamps.web.feature.series.SeriesInfoDto;
@@ -33,7 +32,6 @@
3332
import java.sql.SQLException;
3433
import java.util.Date;
3534

36-
@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods" })
3735
public final class RowMappers {
3836

3937
private RowMappers() {
@@ -168,13 +166,6 @@ public static SeriesFullInfoDto forSeriesFullInfoDto(ResultSet rs, int unused)
168166
);
169167
}
170168

171-
public static EntityWithIdDto forEntityWithIdDto(ResultSet rs, int unused) throws SQLException {
172-
return new EntityWithIdDto(
173-
rs.getInt("id"),
174-
rs.getString("name")
175-
);
176-
}
177-
178169
public static EntityWithParentDto forEntityWithParentDto(ResultSet rs, int unused)
179170
throws SQLException {
180171

0 commit comments

Comments
 (0)