Skip to content

Commit c216ac4

Browse files
committed
refactor(RowMappers): move row mappers for the ru.mystamps.web.feature.account package to this package.
Addressed to #927 No functional changes.
1 parent b2c592b commit c216ac4

File tree

4 files changed

+62
-37
lines changed

4 files changed

+62
-37
lines changed

src/main/java/ru/mystamps/web/feature/account/JdbcUserDao.java

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333

3434
import lombok.RequiredArgsConstructor;
3535

36-
import ru.mystamps.web.support.jdbc.RowMappers;
37-
3836
@RequiredArgsConstructor
3937
public class JdbcUserDao implements UserDao {
4038

src/main/java/ru/mystamps/web/feature/account/JdbcUsersActivationDao.java

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
import lombok.RequiredArgsConstructor;
3232

33-
import ru.mystamps.web.support.jdbc.RowMappers;
34-
3533
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
3634
@RequiredArgsConstructor
3735
public class JdbcUsersActivationDao implements UsersActivationDao {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (C) 2009-2018 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.account;
19+
20+
import java.sql.ResultSet;
21+
import java.sql.SQLException;
22+
23+
// this class only for this package
24+
@SuppressWarnings("PMD.DefaultPackage")
25+
final class RowMappers {
26+
27+
private RowMappers() {
28+
}
29+
30+
/* default */ static UsersActivationDto forUsersActivationDto(ResultSet rs, int unused)
31+
throws SQLException {
32+
33+
return new UsersActivationDto(
34+
rs.getString("email"),
35+
rs.getTimestamp("created_at")
36+
);
37+
}
38+
39+
/* default */ static UsersActivationFullDto forUsersActivationFullDto(ResultSet rs, int unused)
40+
throws SQLException {
41+
42+
return new UsersActivationFullDto(
43+
rs.getString("activation_key"),
44+
rs.getString("email"),
45+
rs.getTimestamp("created_at")
46+
);
47+
}
48+
49+
/* default */ static UserDetails forUserDetails(ResultSet rs, int unused)
50+
throws SQLException {
51+
52+
return new UserDetails(
53+
rs.getInt("id"),
54+
rs.getString("login"),
55+
rs.getString("name"),
56+
rs.getString("hash"),
57+
UserDetails.Role.valueOf(rs.getString("role")),
58+
rs.getString("collection_slug")
59+
);
60+
}
61+
62+
}

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

-33
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525
// CheckStyle: ignore AvoidStarImportCheck for next 1 line
2626
import ru.mystamps.web.dao.dto.*; // NOPMD: UnusedImports
27-
import ru.mystamps.web.feature.account.UserDetails;
28-
import ru.mystamps.web.feature.account.UsersActivationDto;
29-
import ru.mystamps.web.feature.account.UsersActivationFullDto;
3027
import ru.mystamps.web.feature.collection.CollectionInfoDto;
3128
import ru.mystamps.web.feature.collection.SeriesInCollectionDto;
3229
import ru.mystamps.web.feature.collection.SeriesInCollectionWithPriceDto;
@@ -262,25 +259,6 @@ public static SuspiciousActivityDto forSuspiciousActivityDto(ResultSet rs, int u
262259
userAgent
263260
);
264261
}
265-
266-
public static UsersActivationDto forUsersActivationDto(ResultSet rs, int unused)
267-
throws SQLException {
268-
269-
return new UsersActivationDto(
270-
rs.getString("email"),
271-
rs.getTimestamp("created_at")
272-
);
273-
}
274-
275-
public static UsersActivationFullDto forUsersActivationFullDto(ResultSet rs, int unused)
276-
throws SQLException {
277-
278-
return new UsersActivationFullDto(
279-
rs.getString("activation_key"),
280-
rs.getString("email"),
281-
rs.getTimestamp("created_at")
282-
);
283-
}
284262

285263
public static CollectionInfoDto forCollectionInfoDto(ResultSet rs, int unused)
286264
throws SQLException {
@@ -292,17 +270,6 @@ public static CollectionInfoDto forCollectionInfoDto(ResultSet rs, int unused)
292270
);
293271
}
294272

295-
public static UserDetails forUserDetails(ResultSet rs, int unused) throws SQLException {
296-
return new UserDetails(
297-
rs.getInt("id"),
298-
rs.getString("login"),
299-
rs.getString("name"),
300-
rs.getString("hash"),
301-
UserDetails.Role.valueOf(rs.getString("role")),
302-
rs.getString("collection_slug")
303-
);
304-
}
305-
306273
public static EntityWithIdDto forEntityWithIdDto(ResultSet rs, int unused) throws SQLException {
307274
return new EntityWithIdDto(
308275
rs.getInt("id"),

0 commit comments

Comments
 (0)