From b57b86cc87b251aab171e256d12122a6e23aba96 Mon Sep 17 00:00:00 2001 From: janghs Date: Mon, 15 Apr 2024 09:48:33 +0900 Subject: [PATCH] Recommend using isEmpty() instead of size(). --- .../org/apache/ibatis/executor/loader/ResultLoaderMap.java | 4 ++++ .../executor/loader/javassist/JavassistProxyFactory.java | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java b/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java index e7f85681174..e318850c606 100644 --- a/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java +++ b/src/main/java/org/apache/ibatis/executor/loader/ResultLoaderMap.java @@ -70,6 +70,10 @@ public Set getPropertyNames() { public int size() { return loaderMap.size(); } + + public boolean isEmpty() { + return loaderMap.isEmpty(); + } public boolean hasLoader(String property) { return loaderMap.containsKey(property.toUpperCase(Locale.ENGLISH)); diff --git a/src/main/java/org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java b/src/main/java/org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java index 9bdb6d2fe1c..e76efa4f3b9 100644 --- a/src/main/java/org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java +++ b/src/main/java/org/apache/ibatis/executor/loader/javassist/JavassistProxyFactory.java @@ -143,14 +143,14 @@ public Object invoke(Object enhanced, Method method, Method methodProxy, Object[ original = objectFactory.create(type, constructorArgTypes, constructorArgs); } PropertyCopier.copyBeanProperties(type, enhanced, original); - if (lazyLoader.size() > 0) { + if (!lazyLoader.isEmpty()) { return new JavassistSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs); } else { return original; } } - if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) { + if (!lazyLoader.isEmpty() && !FINALIZE_METHOD.equals(methodName)) { if (aggressive || lazyLoadTriggerMethods.contains(methodName)) { lazyLoader.loadAll(); } else if (PropertyNamer.isSetter(methodName)) {