1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.sw4j.tool.annotation.jpa.generator.model;
18
19 import java.util.Collections;
20 import java.util.LinkedList;
21 import java.util.List;
22 import javax.annotation.Nonnull;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAttribute;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlType;
28
29
30
31
32
33
34
35
36 @XmlAccessorType(XmlAccessType.NONE)
37 @XmlType(name = "",
38 propOrder = {
39 "tables",
40 "attributes",
41 })
42 public class Entity {
43
44
45 private final String name;
46
47
48 private final String className;
49
50
51 private List<Attribute> attributes;
52
53
54 private List<Table> tables;
55
56
57
58
59
60
61
62 public Entity(@Nonnull final String name, @Nonnull final String className) {
63 this.name = name;
64 this.className = className;
65 }
66
67
68
69
70
71
72 @Nonnull
73 @XmlAttribute(name = "name", required = true)
74 public String getName() {
75 return this.name;
76 }
77
78
79
80
81
82
83 @Nonnull
84 @XmlAttribute(name = "className", required = true)
85 public String getClassName() {
86 return this.className;
87 }
88
89
90
91
92
93
94 public synchronized void addAttribute(@Nonnull final Attribute attribute) {
95 if (this.attributes == null) {
96 this.attributes = new LinkedList<>();
97 }
98 this.attributes.add(attribute);
99 }
100
101
102
103
104
105
106 @Nonnull
107 @XmlElement(name = "attribute")
108 public synchronized List<Attribute> getAttributes() {
109 return this.attributes == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(this.attributes);
110 }
111
112
113
114
115
116
117 public synchronized void addTable(@Nonnull final Table table) {
118 if (this.tables == null) {
119 this.tables = new LinkedList<>();
120 }
121 this.tables.add(table);
122 }
123
124
125
126
127
128
129 @Nonnull
130 @XmlElement(name = "table")
131 public synchronized List<Table> getTables() {
132 return this.tables == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(this.tables);
133 }
134
135 }