1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package EMOF.impl; |
8 | |
9 | import EMOF.Comment; |
10 | import EMOF.EMOFPackage; |
11 | import EMOF.NamedElement; |
12 | |
13 | import java.util.Collection; |
14 | |
15 | import org.eclipse.emf.common.notify.Notification; |
16 | |
17 | import org.eclipse.emf.common.util.EList; |
18 | |
19 | import org.eclipse.emf.ecore.EClass; |
20 | |
21 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
22 | |
23 | import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
24 | |
25 | /** |
26 | * <!-- begin-user-doc --> |
27 | * An implementation of the model object '<em><b>Comment</b></em>'. |
28 | * <!-- end-user-doc --> |
29 | * <p> |
30 | * The following features are implemented: |
31 | * <ul> |
32 | * <li>{@link EMOF.impl.CommentImpl#getAnnotatedElement <em>Annotated Element</em>}</li> |
33 | * <li>{@link EMOF.impl.CommentImpl#getBody <em>Body</em>}</li> |
34 | * </ul> |
35 | * </p> |
36 | * |
37 | * @generated |
38 | */ |
39 | public class CommentImpl extends ElementImpl implements Comment { |
40 | /** |
41 | * The cached value of the '{@link #getAnnotatedElement() <em>Annotated Element</em>}' reference list. |
42 | * <!-- begin-user-doc --> |
43 | * <!-- end-user-doc --> |
44 | * @see #getAnnotatedElement() |
45 | * @generated |
46 | * @ordered |
47 | */ |
48 | protected EList<NamedElement> annotatedElement; |
49 | |
50 | /** |
51 | * The default value of the '{@link #getBody() <em>Body</em>}' attribute. |
52 | * <!-- begin-user-doc --> |
53 | * <!-- end-user-doc --> |
54 | * @see #getBody() |
55 | * @generated |
56 | * @ordered |
57 | */ |
58 | protected static final String BODY_EDEFAULT = null; |
59 | |
60 | /** |
61 | * The cached value of the '{@link #getBody() <em>Body</em>}' attribute. |
62 | * <!-- begin-user-doc --> |
63 | * <!-- end-user-doc --> |
64 | * @see #getBody() |
65 | * @generated |
66 | * @ordered |
67 | */ |
68 | protected String body = BODY_EDEFAULT; |
69 | |
70 | /** |
71 | * <!-- begin-user-doc --> |
72 | * <!-- end-user-doc --> |
73 | * @generated |
74 | */ |
75 | protected CommentImpl() { |
76 | super(); |
77 | } |
78 | |
79 | /** |
80 | * <!-- begin-user-doc --> |
81 | * <!-- end-user-doc --> |
82 | * @generated |
83 | */ |
84 | @Override |
85 | protected EClass eStaticClass() { |
86 | return EMOFPackage.Literals.COMMENT; |
87 | } |
88 | |
89 | /** |
90 | * <!-- begin-user-doc --> |
91 | * <!-- end-user-doc --> |
92 | * @generated |
93 | */ |
94 | public EList<NamedElement> getAnnotatedElement() { |
95 | if (annotatedElement == null) { |
96 | annotatedElement = new EObjectResolvingEList<NamedElement>(NamedElement.class, this, EMOFPackage.COMMENT__ANNOTATED_ELEMENT); |
97 | } |
98 | return annotatedElement; |
99 | } |
100 | |
101 | /** |
102 | * <!-- begin-user-doc --> |
103 | * <!-- end-user-doc --> |
104 | * @generated |
105 | */ |
106 | public String getBody() { |
107 | return body; |
108 | } |
109 | |
110 | /** |
111 | * <!-- begin-user-doc --> |
112 | * <!-- end-user-doc --> |
113 | * @generated |
114 | */ |
115 | public void setBody(String newBody) { |
116 | String oldBody = body; |
117 | body = newBody; |
118 | if (eNotificationRequired()) |
119 | eNotify(new ENotificationImpl(this, Notification.SET, EMOFPackage.COMMENT__BODY, oldBody, body)); |
120 | } |
121 | |
122 | /** |
123 | * <!-- begin-user-doc --> |
124 | * <!-- end-user-doc --> |
125 | * @generated |
126 | */ |
127 | @Override |
128 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
129 | switch (featureID) { |
130 | case EMOFPackage.COMMENT__ANNOTATED_ELEMENT: |
131 | return getAnnotatedElement(); |
132 | case EMOFPackage.COMMENT__BODY: |
133 | return getBody(); |
134 | } |
135 | return super.eGet(featureID, resolve, coreType); |
136 | } |
137 | |
138 | /** |
139 | * <!-- begin-user-doc --> |
140 | * <!-- end-user-doc --> |
141 | * @generated |
142 | */ |
143 | @SuppressWarnings("unchecked") |
144 | @Override |
145 | public void eSet(int featureID, Object newValue) { |
146 | switch (featureID) { |
147 | case EMOFPackage.COMMENT__ANNOTATED_ELEMENT: |
148 | getAnnotatedElement().clear(); |
149 | getAnnotatedElement().addAll((Collection<? extends NamedElement>)newValue); |
150 | return; |
151 | case EMOFPackage.COMMENT__BODY: |
152 | setBody((String)newValue); |
153 | return; |
154 | } |
155 | super.eSet(featureID, newValue); |
156 | } |
157 | |
158 | /** |
159 | * <!-- begin-user-doc --> |
160 | * <!-- end-user-doc --> |
161 | * @generated |
162 | */ |
163 | @Override |
164 | public void eUnset(int featureID) { |
165 | switch (featureID) { |
166 | case EMOFPackage.COMMENT__ANNOTATED_ELEMENT: |
167 | getAnnotatedElement().clear(); |
168 | return; |
169 | case EMOFPackage.COMMENT__BODY: |
170 | setBody(BODY_EDEFAULT); |
171 | return; |
172 | } |
173 | super.eUnset(featureID); |
174 | } |
175 | |
176 | /** |
177 | * <!-- begin-user-doc --> |
178 | * <!-- end-user-doc --> |
179 | * @generated |
180 | */ |
181 | @Override |
182 | public boolean eIsSet(int featureID) { |
183 | switch (featureID) { |
184 | case EMOFPackage.COMMENT__ANNOTATED_ELEMENT: |
185 | return annotatedElement != null && !annotatedElement.isEmpty(); |
186 | case EMOFPackage.COMMENT__BODY: |
187 | return BODY_EDEFAULT == null ? body != null : !BODY_EDEFAULT.equals(body); |
188 | } |
189 | return super.eIsSet(featureID); |
190 | } |
191 | |
192 | /** |
193 | * <!-- begin-user-doc --> |
194 | * <!-- end-user-doc --> |
195 | * @generated |
196 | */ |
197 | @Override |
198 | public String toString() { |
199 | if (eIsProxy()) return super.toString(); |
200 | |
201 | StringBuffer result = new StringBuffer(super.toString()); |
202 | result.append(" (body: "); |
203 | result.append(body); |
204 | result.append(')'); |
205 | return result.toString(); |
206 | } |
207 | |
208 | } //CommentImpl |