Insist on using CollectionUtils.isEmpty() and StringUtils.hasLength()

search `(\w+) != null && !(\1).isEmpty\(\)`
This commit is contained in:
Yanming Zhou
2024-05-09 14:51:23 +08:00
committed by Juergen Hoeller
parent 8137cc9566
commit a02861f7db
4 changed files with 7 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializ
@Nullable
public V getFirst(K key) {
List<V> values = this.targetMap.get(key);
return (values != null && !values.isEmpty() ? values.get(0) : null);
return (!CollectionUtils.isEmpty(values) ? values.get(0) : null);
}
@Override
@@ -95,7 +95,7 @@ public class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializ
public Map<K, V> toSingleValueMap() {
Map<K, V> singleValueMap = CollectionUtils.newLinkedHashMap(this.targetMap.size());
this.targetMap.forEach((key, values) -> {
if (values != null && !values.isEmpty()) {
if (!CollectionUtils.isEmpty(values)) {
singleValueMap.put(key, values.get(0));
}
});