mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-14 02:05:12 +08:00
企业付款相关接口抽取为一个独立的接口实现类
This commit is contained in:
@@ -32,7 +32,6 @@ public class BeanUtils {
|
||||
* 检查bean里标记为@Required的field是否为空,为空则抛异常
|
||||
*
|
||||
* @param bean 要检查的bean对象
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
public static void checkRequiredFields(Object bean) throws WxErrorException {
|
||||
List<String> requiredFields = Lists.newArrayList();
|
||||
@@ -68,39 +67,4 @@ public class BeanUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将bean按照@XStreamAlias标识的字符串内容生成以之为key的map对象
|
||||
*
|
||||
* @param bean 包含@XStreamAlias的xml bean对象
|
||||
* @return map对象
|
||||
*/
|
||||
public static Map<String, String> xmlBean2Map(Object bean) {
|
||||
Map<String, String> result = Maps.newHashMap();
|
||||
List<Field> fields = new ArrayList<>(Arrays.asList(bean.getClass().getDeclaredFields()));
|
||||
fields.addAll(Arrays.asList(bean.getClass().getSuperclass().getDeclaredFields()));
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
boolean isAccessible = field.isAccessible();
|
||||
field.setAccessible(true);
|
||||
if (field.get(bean) == null) {
|
||||
field.setAccessible(isAccessible);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (field.isAnnotationPresent(XStreamAlias.class)) {
|
||||
result.put(field.getAnnotation(XStreamAlias.class).value(), field.get(bean).toString());
|
||||
} else if (!Modifier.isStatic(field.getModifiers())) {
|
||||
//忽略掉静态成员变量
|
||||
result.put(field.getName(), field.get(bean).toString());
|
||||
}
|
||||
|
||||
field.setAccessible(isAccessible);
|
||||
} catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user