Serializer.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:ibas-framework 作者:
private List<SchemaElement> getSerializedElements(Field[] fields) {
    List<SchemaElement> elements = new ArrayList<>();
    for (Field field : fields) {
        Class<?> elementType = field.getType();
        String elementName = field.getName();
        String wrapperName = null;
        XmlElementWrapper xmlWrapper = field.getAnnotation(XmlElementWrapper.class);
        if (xmlWrapper != null) {
            // 首先判断是否为数组元素
            wrapperName = xmlWrapper.name();
        }
        XmlElement xmlElement = field.getAnnotation(XmlElement.class);
        if (xmlElement != null) {
            if (!xmlElement.name().equals("##default")) {
                elementName = xmlElement.name();
            }
            if (xmlElement.type() != null && !xmlElement.type().getName().startsWith(XmlElement.class.getName())) {
                elementType = xmlElement.type();
            }
        } else {
            continue;
        }
        if (elementName == null) {
            continue;
        }
        if (elementType == null) {
            continue;
        }
        elements.add(new SchemaElement(elementName, wrapperName, elementType));
    }
    return elements;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号