1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.impl;
26
27 import static net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.tag.PlantUMLClassesDiagramElementTag.CLASS_TAG;
28 import static net.sourceforge.plantumldependency.common.constants.CommonConstants.BLANK_STRING;
29 import net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.AbstractPlantUMLClassesDiagramElement;
30 import net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.PlantUMLClassesDiagramClassElement;
31 import net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.PlantUMLClassesDiagramElement;
32 import net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.stereotype.PlantUMLStereotype;
33 import net.sourceforge.plantumldependency.cli.plantumldiagram.classes.element.tag.PlantUMLClassesDiagramElementTag;
34
35
36
37
38
39
40
41
42 public class PlantUMLClassesDiagramClassElementImpl extends AbstractPlantUMLClassesDiagramElement implements
43 PlantUMLClassesDiagramClassElement {
44
45
46 private static final long serialVersionUID = 9113761739200276659L;
47
48
49 private PlantUMLStereotype stereotype;
50
51
52
53
54
55
56
57
58 public PlantUMLClassesDiagramClassElementImpl(final String fullName) {
59 this(fullName, null);
60 }
61
62
63
64
65
66
67
68
69
70
71
72
73
74 public PlantUMLClassesDiagramClassElementImpl(final String fullName, final PlantUMLClassesDiagramElementTag tag,
75 final PlantUMLStereotype stereotyp) {
76 super(fullName, tag);
77 stereotype = stereotyp;
78 }
79
80
81
82
83
84
85
86
87
88
89 public PlantUMLClassesDiagramClassElementImpl(final String fullName, final PlantUMLStereotype stereotyp) {
90 super(fullName, CLASS_TAG);
91 stereotype = stereotyp;
92 }
93
94
95
96
97
98
99 @Override
100 public PlantUMLClassesDiagramElement deepClone() {
101 final PlantUMLClassesDiagramClassElementImpl p = (PlantUMLClassesDiagramClassElementImpl) super.deepClone();
102 p.stereotype = getStereotype() == null ? null : getStereotype().deepClone();
103 return p;
104 }
105
106
107
108
109
110
111 @Override
112 public boolean equals(final Object obj) {
113 if (this == obj) {
114 return true;
115 }
116 if (!super.equals(obj)) {
117 return false;
118 }
119 if (getClass() != obj.getClass()) {
120 return false;
121 }
122 final PlantUMLClassesDiagramClassElementImpl other = (PlantUMLClassesDiagramClassElementImpl) obj;
123 if (stereotype == null) {
124 if (other.stereotype != null) {
125 return false;
126 }
127 } else if (!stereotype.equals(other.stereotype)) {
128 return false;
129 }
130 return true;
131 }
132
133
134
135
136
137
138 @Override
139 protected String getAdditionalPlantUMLTextDescription() {
140 return getStereotype() != null ? getStereotype().getPlantUMLTextDescription() : BLANK_STRING;
141 }
142
143
144
145
146
147
148 @Override
149 public PlantUMLStereotype getStereotype() {
150 return stereotype;
151 }
152
153
154
155
156
157
158 @Override
159 public int hashCode() {
160 final int prime = 31;
161 int result = super.hashCode();
162 result = prime * result + ((stereotype == null) ? 0 : stereotype.hashCode());
163 return result;
164 }
165
166
167
168
169
170
171 @Override
172 public String toString() {
173 return getClass().getSimpleName() + " [" + super.toString() + ",stereotype=" + stereotype + "]";
174 }
175 }