mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
Repository objects refactoring
SQL query is limited by 1, so there will be two cases - whether collection is empty or not. We should user convenient shortcut for checking emptiness of collection
This commit is contained in:
parent
a5b2c9f8c0
commit
e22951c68e
2 changed files with 4 additions and 4 deletions
|
@ -71,7 +71,7 @@ public enum UserStatsRepository {
|
|||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
qb.limit(1L).where().eq("userName", userName);
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
if (users.size() == 1) {
|
||||
if (!users.isEmpty()) {
|
||||
return users.get(0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
@ -95,7 +95,7 @@ public enum UserStatsRepository {
|
|||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
qb.orderBy("endTimeMs", false).limit(1L);
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
if (users.size() == 1) {
|
||||
if (!users.isEmpty()) {
|
||||
return users.get(0).getEndTimeMs();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
@ -115,7 +115,7 @@ public enum ExpansionRepository {
|
|||
QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder();
|
||||
qb.limit(1L).where().eq("code", new SelectArg(setCode));
|
||||
List<ExpansionInfo> expansions = expansionDao.query(qb.prepare());
|
||||
if (expansions.size() > 0) {
|
||||
if (!expansions.isEmpty()) {
|
||||
set = expansions.get(0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
@ -129,7 +129,7 @@ public enum ExpansionRepository {
|
|||
QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder();
|
||||
qb.limit(1L).where().eq("name", new SelectArg(setName));
|
||||
List<ExpansionInfo> expansions = expansionDao.query(qb.prepare());
|
||||
if (expansions.size() > 0) {
|
||||
if (!expansions.isEmpty()) {
|
||||
set = expansions.get(0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
Loading…
Reference in a new issue