!856 update 优化代码,简化类型检查

* update 优化代码,简化类型检查
This commit is contained in:
AprilWind
2026-06-10 06:38:46 +00:00
committed by 疯狂的狮子Li
parent fc43e368b7
commit 0b37392a8f
12 changed files with 44 additions and 29 deletions
@@ -109,16 +109,20 @@ public class JsonValueEnhancer {
* @param visited 已访问对象集合,用于避免循环引用
*/
private void collectValue(Object value, JsonEnhancementContext context, IdentityHashMap<Object, Boolean> visited) {
if (value == null) {
return;
}
if (value instanceof Map<?, ?> map) {
map.values().forEach(child -> collectValue(child, context, visited));
return;
}
if (value instanceof Iterable<?> iterable) {
iterable.forEach(child -> collectValue(child, context, visited));
return;
switch (value) {
case null -> {
return;
}
case Map<?, ?> map -> {
map.values().forEach(child -> collectValue(child, context, visited));
return;
}
case Iterable<?> iterable -> {
iterable.forEach(child -> collectValue(child, context, visited));
return;
}
default -> {
}
}
if (value.getClass().isArray()) {
int length = Array.getLength(value);