package gov.services.result.v3.api.resource;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.util.ArrayList;
import java.util.List;
public class EntityUtils {
public static void main(String[] args) {
System.out.println("Holle world!");
}
/**
* 获取有值得属性名
* @param source
* @return
*/
public static String[] getValuePropertyNames(Object source) {
final BeanWrapper src = new BeanWrapperImpl(source);
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
List<String> emptyNames = new ArrayList<String>();
for (java.beans.PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName());
if (null != srcValue)
emptyNames.add(pd.getName());
}
String[] result = new String[emptyNames.size()];
return emptyNames.toArray(result);
}
}