public static void addAnnotationInfo()

in bytekit-core/src/main/java/com/alibaba/bytekit/utils/AsmAnnotationUtils.java [98:136]


    public static void addAnnotationInfo(List<AnnotationNode> annotations, String annotationType, String key,
            String value) {

        AnnotationNode annotationNode = null;
        for (AnnotationNode tmp : annotations) {
            if (tmp.desc.equals(annotationType)) {
                annotationNode = tmp;
            }
        }

        if (annotationNode == null) {
            annotationNode = new AnnotationNode(annotationType);
            annotations.add(annotationNode);
        }

        if (annotationNode.values == null) {
            annotationNode.values = new ArrayList<Object>();
        }

        // 查找有没有对应的key
        String name = null;
        List<String> values = null;
        Iterator<Object> iterator = annotationNode.values.iterator();
        while (iterator.hasNext()) {
            if (key.equals(iterator.next())) {
                values = (List<String>) iterator.next();
            } else {
                iterator.next();
            }
        }
        if (values == null) {
            values = new ArrayList<String>();
            annotationNode.values.add(key);
            annotationNode.values.add(values);
        }
        if (!values.contains(values)) {
            values.add(value);
        }
    }