1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Obeo.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Obeo - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.emf
.compare
.uml2
.profile
.test
.uml2comparetestprofile
.impl
;
13 import java
.util
.Collection
;
15 import org
.eclipse
.emf
.common
.notify
.Notification
;
16 import org
.eclipse
.emf
.common
.util
.EList
;
17 import org
.eclipse
.emf
.compare
.uml2
.profile
.test
.uml2comparetestprofile
.ACliche
;
18 import org
.eclipse
.emf
.compare
.uml2
.profile
.test
.uml2comparetestprofile
.UML2CompareTestProfilePackage
;
19 import org
.eclipse
.emf
.ecore
.EClass
;
20 import org
.eclipse
.emf
.ecore
.InternalEObject
;
21 import org
.eclipse
.emf
.ecore
.impl
.ENotificationImpl
;
22 import org
.eclipse
.emf
.ecore
.impl
.EObjectImpl
;
23 import org
.eclipse
.emf
.ecore
.util
.EDataTypeUniqueEList
;
24 import org
.eclipse
.emf
.ecore
.util
.EObjectResolvingEList
;
27 * <!-- begin-user-doc --> An implementation of the model object '<em><b>ACliche</b></em>'. <!-- end-user-doc
30 * The following features are implemented:
33 * {@link org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.impl.AClicheImpl#getSingleValuedAttribute
34 * <em>Single Valued Attribute</em>}</li>
36 * {@link org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.impl.AClicheImpl#getManyValuedAttribute
37 * <em>Many Valued Attribute</em>}</li>
39 * {@link org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.impl.AClicheImpl#getSingleValuedReference
40 * <em>Single Valued Reference</em>}</li>
42 * {@link org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.impl.AClicheImpl#getManyValuedReference
43 * <em>Many Valued Reference</em>}</li>
44 * <li>{@link org.eclipse.emf.compare.uml2.profile.test.uml2comparetestprofile.impl.AClicheImpl#getBase_Class
45 * <em>Base Class</em>}</li>
51 public class AClicheImpl
extends EObjectImpl
implements ACliche
{
53 * The default value of the '{@link #getSingleValuedAttribute() <em>Single Valued Attribute</em>}'
54 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
56 * @see #getSingleValuedAttribute()
60 protected static final String SINGLE_VALUED_ATTRIBUTE_EDEFAULT
= null;
63 * The cached value of the '{@link #getSingleValuedAttribute() <em>Single Valued Attribute</em>}'
64 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
66 * @see #getSingleValuedAttribute()
70 protected String singleValuedAttribute
= SINGLE_VALUED_ATTRIBUTE_EDEFAULT
;
73 * The cached value of the '{@link #getManyValuedAttribute() <em>Many Valued Attribute</em>}' attribute
74 * list. <!-- begin-user-doc --> <!-- end-user-doc -->
76 * @see #getManyValuedAttribute()
80 protected EList
<String
> manyValuedAttribute
;
83 * The cached value of the '{@link #getSingleValuedReference() <em>Single Valued Reference</em>}'
84 * reference. <!-- begin-user-doc --> <!-- end-user-doc -->
86 * @see #getSingleValuedReference()
90 protected org
.eclipse
.uml2
.uml
.Class singleValuedReference
;
93 * The cached value of the '{@link #getManyValuedReference() <em>Many Valued Reference</em>}' reference
94 * list. <!-- begin-user-doc --> <!-- end-user-doc -->
96 * @see #getManyValuedReference()
100 protected EList
<org
.eclipse
.uml2
.uml
.Class
> manyValuedReference
;
103 * The cached value of the '{@link #getBase_Class() <em>Base Class</em>}' reference. <!-- begin-user-doc
104 * --> <!-- end-user-doc -->
106 * @see #getBase_Class()
110 protected org
.eclipse
.uml2
.uml
.Class base_Class
;
113 * <!-- begin-user-doc --> <!-- end-user-doc -->
117 protected AClicheImpl() {
122 * <!-- begin-user-doc --> <!-- end-user-doc -->
127 protected EClass
eStaticClass() {
128 return UML2CompareTestProfilePackage
.Literals
.ACLICHE
;
132 * <!-- begin-user-doc --> <!-- end-user-doc -->
136 public String
getSingleValuedAttribute() {
137 return singleValuedAttribute
;
141 * <!-- begin-user-doc --> <!-- end-user-doc -->
145 public void setSingleValuedAttribute(String newSingleValuedAttribute
) {
146 String oldSingleValuedAttribute
= singleValuedAttribute
;
147 singleValuedAttribute
= newSingleValuedAttribute
;
148 if (eNotificationRequired())
149 eNotify(new ENotificationImpl(this, Notification
.SET
,
150 UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
, oldSingleValuedAttribute
,
151 singleValuedAttribute
));
155 * <!-- begin-user-doc --> <!-- end-user-doc -->
159 public EList
<String
> getManyValuedAttribute() {
160 if (manyValuedAttribute
== null) {
161 manyValuedAttribute
= new EDataTypeUniqueEList
<String
>(String
.class, this,
162 UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
);
164 return manyValuedAttribute
;
168 * <!-- begin-user-doc --> <!-- end-user-doc -->
172 public org
.eclipse
.uml2
.uml
.Class
getSingleValuedReference() {
173 if (singleValuedReference
!= null && singleValuedReference
.eIsProxy()) {
174 InternalEObject oldSingleValuedReference
= (InternalEObject
)singleValuedReference
;
175 singleValuedReference
= (org
.eclipse
.uml2
.uml
.Class
)eResolveProxy(oldSingleValuedReference
);
176 if (singleValuedReference
!= oldSingleValuedReference
) {
177 if (eNotificationRequired())
178 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
,
179 UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
,
180 oldSingleValuedReference
, singleValuedReference
));
183 return singleValuedReference
;
187 * <!-- begin-user-doc --> <!-- end-user-doc -->
191 public org
.eclipse
.uml2
.uml
.Class
basicGetSingleValuedReference() {
192 return singleValuedReference
;
196 * <!-- begin-user-doc --> <!-- end-user-doc -->
200 public void setSingleValuedReference(org
.eclipse
.uml2
.uml
.Class newSingleValuedReference
) {
201 org
.eclipse
.uml2
.uml
.Class oldSingleValuedReference
= singleValuedReference
;
202 singleValuedReference
= newSingleValuedReference
;
203 if (eNotificationRequired())
204 eNotify(new ENotificationImpl(this, Notification
.SET
,
205 UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
, oldSingleValuedReference
,
206 singleValuedReference
));
210 * <!-- begin-user-doc --> <!-- end-user-doc -->
214 public EList
<org
.eclipse
.uml2
.uml
.Class
> getManyValuedReference() {
215 if (manyValuedReference
== null) {
216 manyValuedReference
= new EObjectResolvingEList
<org
.eclipse
.uml2
.uml
.Class
>(
217 org
.eclipse
.uml2
.uml
.Class
.class, this,
218 UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
);
220 return manyValuedReference
;
224 * <!-- begin-user-doc --> <!-- end-user-doc -->
228 public org
.eclipse
.uml2
.uml
.Class
getManyValuedReference(String name
) {
229 return getManyValuedReference(name
, false, null);
233 * <!-- begin-user-doc --> <!-- end-user-doc -->
237 public org
.eclipse
.uml2
.uml
.Class
getManyValuedReference(String name
, boolean ignoreCase
, EClass eClass
) {
238 manyValuedReferenceLoop
: for (org
.eclipse
.uml2
.uml
.Class manyValuedReference
: getManyValuedReference()) {
239 if (eClass
!= null && !eClass
.isInstance(manyValuedReference
))
240 continue manyValuedReferenceLoop
;
242 && !(ignoreCase ? name
.equalsIgnoreCase(manyValuedReference
.getName()) : name
243 .equals(manyValuedReference
.getName())))
244 continue manyValuedReferenceLoop
;
245 return manyValuedReference
;
251 * <!-- begin-user-doc --> <!-- end-user-doc -->
255 public org
.eclipse
.uml2
.uml
.Class
getBase_Class() {
256 if (base_Class
!= null && base_Class
.eIsProxy()) {
257 InternalEObject oldBase_Class
= (InternalEObject
)base_Class
;
258 base_Class
= (org
.eclipse
.uml2
.uml
.Class
)eResolveProxy(oldBase_Class
);
259 if (base_Class
!= oldBase_Class
) {
260 if (eNotificationRequired())
261 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
,
262 UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
, oldBase_Class
, base_Class
));
269 * <!-- begin-user-doc --> <!-- end-user-doc -->
273 public org
.eclipse
.uml2
.uml
.Class
basicGetBase_Class() {
278 * <!-- begin-user-doc --> <!-- end-user-doc -->
282 public void setBase_Class(org
.eclipse
.uml2
.uml
.Class newBase_Class
) {
283 org
.eclipse
.uml2
.uml
.Class oldBase_Class
= base_Class
;
284 base_Class
= newBase_Class
;
285 if (eNotificationRequired())
286 eNotify(new ENotificationImpl(this, Notification
.SET
,
287 UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
, oldBase_Class
, base_Class
));
291 * <!-- begin-user-doc --> <!-- end-user-doc -->
296 public Object
eGet(int featureID
, boolean resolve
, boolean coreType
) {
298 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
299 return getSingleValuedAttribute();
300 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
301 return getManyValuedAttribute();
302 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
304 return getSingleValuedReference();
305 return basicGetSingleValuedReference();
306 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
307 return getManyValuedReference();
308 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
310 return getBase_Class();
311 return basicGetBase_Class();
313 return super.eGet(featureID
, resolve
, coreType
);
317 * <!-- begin-user-doc --> <!-- end-user-doc -->
321 @SuppressWarnings("unchecked")
323 public void eSet(int featureID
, Object newValue
) {
325 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
326 setSingleValuedAttribute((String
)newValue
);
328 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
329 getManyValuedAttribute().clear();
330 getManyValuedAttribute().addAll((Collection
<?
extends String
>)newValue
);
332 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
333 setSingleValuedReference((org
.eclipse
.uml2
.uml
.Class
)newValue
);
335 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
336 getManyValuedReference().clear();
337 getManyValuedReference().addAll((Collection
<?
extends org
.eclipse
.uml2
.uml
.Class
>)newValue
);
339 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
340 setBase_Class((org
.eclipse
.uml2
.uml
.Class
)newValue
);
343 super.eSet(featureID
, newValue
);
347 * <!-- begin-user-doc --> <!-- end-user-doc -->
352 public void eUnset(int featureID
) {
354 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
355 setSingleValuedAttribute(SINGLE_VALUED_ATTRIBUTE_EDEFAULT
);
357 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
358 getManyValuedAttribute().clear();
360 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
361 setSingleValuedReference((org
.eclipse
.uml2
.uml
.Class
)null);
363 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
364 getManyValuedReference().clear();
366 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
367 setBase_Class((org
.eclipse
.uml2
.uml
.Class
)null);
370 super.eUnset(featureID
);
374 * <!-- begin-user-doc --> <!-- end-user-doc -->
379 public boolean eIsSet(int featureID
) {
381 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
382 return SINGLE_VALUED_ATTRIBUTE_EDEFAULT
== null ? singleValuedAttribute
!= null
383 : !SINGLE_VALUED_ATTRIBUTE_EDEFAULT
.equals(singleValuedAttribute
);
384 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
385 return manyValuedAttribute
!= null && !manyValuedAttribute
.isEmpty();
386 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
387 return singleValuedReference
!= null;
388 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
389 return manyValuedReference
!= null && !manyValuedReference
.isEmpty();
390 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
391 return base_Class
!= null;
393 return super.eIsSet(featureID
);
397 * <!-- begin-user-doc --> <!-- end-user-doc -->
402 public String
toString() {
404 return super.toString();
406 StringBuffer result
= new StringBuffer(super.toString());
407 result
.append(" (singleValuedAttribute: "); //$NON-NLS-1$
408 result
.append(singleValuedAttribute
);
409 result
.append(", manyValuedAttribute: "); //$NON-NLS-1$
410 result
.append(manyValuedAttribute
);
412 return result
.toString();