2
zyy
2025-11-14 6e85d12eab8accba3dd6731d9273388bd7f8d68c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.yami.trading.common.util;
 
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
 
import java.util.HashSet;
import java.util.Set;
 
public class CopyBeanUtils {
 
    public static String[] getNullPropertyNames(Object source) {
        final BeanWrapper src = new BeanWrapperImpl(source);
        java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
        Set<String> emptyNames = new HashSet<>();
        for(java.beans.PropertyDescriptor pd : pds) {
            Object srcValue = src.getPropertyValue(pd.getName());
            if (srcValue == null) {
                emptyNames.add(pd.getName());
            }
        }
        String[] result = new String[emptyNames.size()];
        return (String[]) emptyNames.toArray(result);
    }
}