1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.generator.api.dom.xml;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 public class XmlElement implements VisitableElement {
22
23 private final List<Attribute> attributes = new ArrayList<>();
24
25 private final List<VisitableElement> elements = new ArrayList<>();
26
27 private String name;
28
29 public XmlElement(String name) {
30 this.name = name;
31 }
32
33
34
35
36
37
38
39 public XmlElement(XmlElement original) {
40 super();
41 attributes.addAll(original.attributes);
42 elements.addAll(original.elements);
43 this.name = original.name;
44 }
45
46 public List<Attribute> getAttributes() {
47 return attributes;
48 }
49
50 public void addAttribute(Attribute attribute) {
51 attributes.add(attribute);
52 }
53
54 public List<VisitableElement> getElements() {
55 return elements;
56 }
57
58 public void addElement(VisitableElement element) {
59 elements.add(element);
60 }
61
62 public void addElement(int index, VisitableElement element) {
63 elements.add(index, element);
64 }
65
66 public String getName() {
67 return name;
68 }
69
70 public boolean hasChildren() {
71 return !elements.isEmpty();
72 }
73
74 public void setName(String name) {
75 this.name = name;
76 }
77
78 @Override
79 public <R> R accept(ElementVisitor<R> visitor) {
80 return visitor.visit(this);
81 }
82 }