Skip to content

Commit b3c5ffa

Browse files
committed
Refine some code
1 parent 4d26fc2 commit b3c5ffa

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public XNode getSqlFragment(String refid) {
108108
private void configurationElement(XNode context) {
109109
try {
110110
String namespace = context.getStringAttribute("namespace");
111-
if (namespace == null || namespace.equals("")) {
111+
if (namespace == null || namespace.isEmpty()) {
112112
throw new BuilderException("Mapper's namespace cannot be empty");
113113
}
114114
builderAssistant.setCurrentNamespace(namespace);

src/main/java/org/apache/ibatis/executor/ReuseExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private Statement prepareStatement(StatementHandler handler, Log statementLog) t
9595

9696
private boolean hasStatementFor(String sql) {
9797
try {
98-
return statementMap.keySet().contains(sql) && !statementMap.get(sql).getConnection().isClosed();
98+
return statementMap.containsKey(sql) && !statementMap.get(sql).getConnection().isClosed();
9999
} catch (SQLException e) {
100100
return false;
101101
}

src/main/java/org/apache/ibatis/jdbc/ScriptRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ private void handleLine(StringBuilder command, String line) throws SQLException
208208
}
209209
println(trimmedLine);
210210
} else if (commandReadyToExecute(trimmedLine)) {
211-
command.append(line.substring(0, line.lastIndexOf(delimiter)));
211+
command.append(line, 0, line.lastIndexOf(delimiter));
212212
command.append(LINE_SEPARATOR);
213213
println(command);
214214
executeStatement(command.toString());

src/main/java/org/apache/ibatis/reflection/Reflector.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,9 @@ private void addMethodConflict(Map<String, List<Method>> conflictingMethods, Str
149149
}
150150

151151
private void resolveSetterConflicts(Map<String, List<Method>> conflictingSetters) {
152-
for (String propName : conflictingSetters.keySet()) {
153-
List<Method> setters = conflictingSetters.get(propName);
152+
for (Entry<String, List<Method>> entry : conflictingSetters.entrySet()) {
153+
String propName = entry.getKey();
154+
List<Method> setters = entry.getValue();
154155
Class<?> getterType = getTypes.get(propName);
155156
boolean isGetterAmbiguous = getMethods.get(propName) instanceof AmbiguousMethodInvoker;
156157
boolean isSetterAmbiguous = false;
@@ -428,7 +429,7 @@ public String[] getSetablePropertyNames() {
428429
* @return True if the object has a writable property by the name
429430
*/
430431
public boolean hasSetter(String propertyName) {
431-
return setMethods.keySet().contains(propertyName);
432+
return setMethods.containsKey(propertyName);
432433
}
433434

434435
/**
@@ -438,7 +439,7 @@ public boolean hasSetter(String propertyName) {
438439
* @return True if the object has a readable property by the name
439440
*/
440441
public boolean hasGetter(String propertyName) {
441-
return getMethods.keySet().contains(propertyName);
442+
return getMethods.containsKey(propertyName);
442443
}
443444

444445
public String findPropertyName(String name) {

src/test/java/org/apache/ibatis/submitted/blocking_cache/Person.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public void setLastname(String lastname) {
5959
@Override
6060
public String toString() {
6161
StringBuilder sb = new StringBuilder();
62-
sb.append("id=" + id);
63-
sb.append(", lastname=" + lastname);
64-
sb.append(", firstname=" + firstname);
62+
sb.append("id=").append(id);
63+
sb.append(", lastname=").append(lastname);
64+
sb.append(", firstname=").append(firstname);
6565
return sb.toString();
6666
}
6767

src/test/java/org/apache/ibatis/submitted/cache/Person.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public void setLastname(String lastname) {
5959
@Override
6060
public String toString() {
6161
StringBuilder sb = new StringBuilder();
62-
sb.append("id=" + id);
63-
sb.append(", lastname=" + lastname);
64-
sb.append(", firstname=" + firstname);
62+
sb.append("id=").append(id);
63+
sb.append(", lastname=").append(lastname);
64+
sb.append(", firstname=").append(firstname);
6565
return sb.toString();
6666
}
6767

src/test/java/org/apache/ibatis/submitted/mapper_type_parameter/BaseMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public String provideInsert(Map<String, Object> map) {
7373
} else {
7474
sql.append(",");
7575
}
76-
sql.append(" (#{list[" + i + "].id}, #{list[" + i + "].name})");
76+
sql.append(" (#{list[").append(i).append("].id}, #{list[").append(i).append("].name})");
7777
}
7878
return sql == null ? "" : sql.toString();
7979
}

0 commit comments

Comments
 (0)