private void validateCollection(Field f, Object obj) throws IllegalArgumentException, IllegalAccessException {
XmlType xtype = obj.getClass().getAnnotation(XmlType.class);
if (xtype == null) {
return;
}
String elementName = xtype.name();
logger.debug(String.format("validating %s->%s", elementName, f.getName()));
Collection l = (Collection) f.get(obj);
XmlElement eat = f.getAnnotation(XmlElement.class);
if (eat != null && (eat.required() && (l == null || l.isEmpty()))) {
throw new IllegalArgumentException(String.format("field[%s] of element[%s] is mandatory, cannot be missed", f.getName(), elementName));
}
XmlAttribute aat = f.getAnnotation(XmlAttribute.class);
if (aat != null && (aat.required() && (l == null || l.isEmpty()))) {
throw new IllegalArgumentException(String.format("field[%s] of element[%s] is mandatory, cannot be missed", aat.name(), elementName));
}
if (l != null) {
Object val = l.iterator().next();
if (val != null) {
validateObject(val);
}
}
}
DeployerValidator.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:zstack
作者:
评论列表
文章目录