Skip to content

Commit 7ae38a2

Browse files
authored
Merge pull request mybatis#3139 from dukbong/Replace
Recommend using isEmpty() instead of size().
2 parents 4a8e2ea + b57b86c commit 7ae38a2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public Set<String> getPropertyNames() {
7070
public int size() {
7171
return loaderMap.size();
7272
}
73+
74+
public boolean isEmpty() {
75+
return loaderMap.isEmpty();
76+
}
7377

7478
public boolean hasLoader(String property) {
7579
return loaderMap.containsKey(property.toUpperCase(Locale.ENGLISH));

src/main/java/org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ public Object invoke(Object enhanced, Method method, Method methodProxy, Object[
143143
original = objectFactory.create(type, constructorArgTypes, constructorArgs);
144144
}
145145
PropertyCopier.copyBeanProperties(type, enhanced, original);
146-
if (lazyLoader.size() > 0) {
146+
if (!lazyLoader.isEmpty()) {
147147
return new JavassistSerialStateHolder(original, lazyLoader.getProperties(), objectFactory,
148148
constructorArgTypes, constructorArgs);
149149
} else {
150150
return original;
151151
}
152152
}
153-
if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
153+
if (!lazyLoader.isEmpty() && !FINALIZE_METHOD.equals(methodName)) {
154154
if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
155155
lazyLoader.loadAll();
156156
} else if (PropertyNamer.isSetter(methodName)) {

0 commit comments

Comments
 (0)