1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 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
));
156 * <!-- begin-user-doc --> <!-- end-user-doc -->
160 public EList
<String
> getManyValuedAttribute() {
161 if (manyValuedAttribute
== null) {
162 manyValuedAttribute
= new EDataTypeUniqueEList
<String
>(String
.class, this,
163 UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
);
165 return manyValuedAttribute
;
169 * <!-- begin-user-doc --> <!-- end-user-doc -->
173 public org
.eclipse
.uml2
.uml
.Class
getSingleValuedReference() {
174 if (singleValuedReference
!= null && singleValuedReference
.eIsProxy()) {
175 InternalEObject oldSingleValuedReference
= (InternalEObject
)singleValuedReference
;
176 singleValuedReference
= (org
.eclipse
.uml2
.uml
.Class
)eResolveProxy(oldSingleValuedReference
);
177 if (singleValuedReference
!= oldSingleValuedReference
) {
178 if (eNotificationRequired()) {
179 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
,
180 UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
,
181 oldSingleValuedReference
, singleValuedReference
));
185 return singleValuedReference
;
189 * <!-- begin-user-doc --> <!-- end-user-doc -->
193 public org
.eclipse
.uml2
.uml
.Class
basicGetSingleValuedReference() {
194 return singleValuedReference
;
198 * <!-- begin-user-doc --> <!-- end-user-doc -->
202 public void setSingleValuedReference(org
.eclipse
.uml2
.uml
.Class newSingleValuedReference
) {
203 org
.eclipse
.uml2
.uml
.Class oldSingleValuedReference
= singleValuedReference
;
204 singleValuedReference
= newSingleValuedReference
;
205 if (eNotificationRequired()) {
206 eNotify(new ENotificationImpl(this, Notification
.SET
,
207 UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
, oldSingleValuedReference
,
208 singleValuedReference
));
213 * <!-- begin-user-doc --> <!-- end-user-doc -->
217 public EList
<org
.eclipse
.uml2
.uml
.Class
> getManyValuedReference() {
218 if (manyValuedReference
== null) {
219 manyValuedReference
= new EObjectResolvingEList
<org
.eclipse
.uml2
.uml
.Class
>(
220 org
.eclipse
.uml2
.uml
.Class
.class, this,
221 UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
);
223 return manyValuedReference
;
227 * <!-- begin-user-doc --> <!-- end-user-doc -->
231 public org
.eclipse
.uml2
.uml
.Class
getManyValuedReference(String name
) {
232 return getManyValuedReference(name
, false, null);
236 * <!-- begin-user-doc --> <!-- end-user-doc -->
240 public org
.eclipse
.uml2
.uml
.Class
getManyValuedReference(String name
, boolean ignoreCase
, EClass eClass
) {
241 manyValuedReferenceLoop
: for (org
.eclipse
.uml2
.uml
.Class manyValuedReference
: getManyValuedReference()) {
242 if (eClass
!= null && !eClass
.isInstance(manyValuedReference
)) {
243 continue manyValuedReferenceLoop
;
246 && !(ignoreCase ? name
.equalsIgnoreCase(manyValuedReference
.getName()) : name
247 .equals(manyValuedReference
.getName()))) {
248 continue manyValuedReferenceLoop
;
250 return manyValuedReference
;
256 * <!-- begin-user-doc --> <!-- end-user-doc -->
260 public org
.eclipse
.uml2
.uml
.Class
getBase_Class() {
261 if (base_Class
!= null && base_Class
.eIsProxy()) {
262 InternalEObject oldBase_Class
= (InternalEObject
)base_Class
;
263 base_Class
= (org
.eclipse
.uml2
.uml
.Class
)eResolveProxy(oldBase_Class
);
264 if (base_Class
!= oldBase_Class
) {
265 if (eNotificationRequired()) {
266 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
,
267 UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
, oldBase_Class
, base_Class
));
275 * <!-- begin-user-doc --> <!-- end-user-doc -->
279 public org
.eclipse
.uml2
.uml
.Class
basicGetBase_Class() {
284 * <!-- begin-user-doc --> <!-- end-user-doc -->
288 public void setBase_Class(org
.eclipse
.uml2
.uml
.Class newBase_Class
) {
289 org
.eclipse
.uml2
.uml
.Class oldBase_Class
= base_Class
;
290 base_Class
= newBase_Class
;
291 if (eNotificationRequired()) {
292 eNotify(new ENotificationImpl(this, Notification
.SET
,
293 UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
, oldBase_Class
, base_Class
));
298 * <!-- begin-user-doc --> <!-- end-user-doc -->
303 public Object
eGet(int featureID
, boolean resolve
, boolean coreType
) {
305 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
306 return getSingleValuedAttribute();
307 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
308 return getManyValuedAttribute();
309 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
311 return getSingleValuedReference();
313 return basicGetSingleValuedReference();
314 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
315 return getManyValuedReference();
316 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
318 return getBase_Class();
320 return basicGetBase_Class();
322 return super.eGet(featureID
, resolve
, coreType
);
326 * <!-- begin-user-doc --> <!-- end-user-doc -->
330 @SuppressWarnings("unchecked")
332 public void eSet(int featureID
, Object newValue
) {
334 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
335 setSingleValuedAttribute((String
)newValue
);
337 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
338 getManyValuedAttribute().clear();
339 getManyValuedAttribute().addAll((Collection
<?
extends String
>)newValue
);
341 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
342 setSingleValuedReference((org
.eclipse
.uml2
.uml
.Class
)newValue
);
344 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
345 getManyValuedReference().clear();
346 getManyValuedReference().addAll((Collection
<?
extends org
.eclipse
.uml2
.uml
.Class
>)newValue
);
348 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
349 setBase_Class((org
.eclipse
.uml2
.uml
.Class
)newValue
);
352 super.eSet(featureID
, newValue
);
356 * <!-- begin-user-doc --> <!-- end-user-doc -->
361 public void eUnset(int featureID
) {
363 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
364 setSingleValuedAttribute(SINGLE_VALUED_ATTRIBUTE_EDEFAULT
);
366 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
367 getManyValuedAttribute().clear();
369 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
370 setSingleValuedReference((org
.eclipse
.uml2
.uml
.Class
)null);
372 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
373 getManyValuedReference().clear();
375 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
376 setBase_Class((org
.eclipse
.uml2
.uml
.Class
)null);
379 super.eUnset(featureID
);
383 * <!-- begin-user-doc --> <!-- end-user-doc -->
388 public boolean eIsSet(int featureID
) {
390 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_ATTRIBUTE
:
391 return SINGLE_VALUED_ATTRIBUTE_EDEFAULT
== null ? singleValuedAttribute
!= null
392 : !SINGLE_VALUED_ATTRIBUTE_EDEFAULT
.equals(singleValuedAttribute
);
393 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_ATTRIBUTE
:
394 return manyValuedAttribute
!= null && !manyValuedAttribute
.isEmpty();
395 case UML2CompareTestProfilePackage
.ACLICHE__SINGLE_VALUED_REFERENCE
:
396 return singleValuedReference
!= null;
397 case UML2CompareTestProfilePackage
.ACLICHE__MANY_VALUED_REFERENCE
:
398 return manyValuedReference
!= null && !manyValuedReference
.isEmpty();
399 case UML2CompareTestProfilePackage
.ACLICHE__BASE_CLASS
:
400 return base_Class
!= null;
402 return super.eIsSet(featureID
);
406 * <!-- begin-user-doc --> <!-- end-user-doc -->
411 public String
toString() {
413 return super.toString();
416 StringBuffer result
= new StringBuffer(super.toString());
417 result
.append(" (singleValuedAttribute: "); //$NON-NLS-1$
418 result
.append(singleValuedAttribute
);
419 result
.append(", manyValuedAttribute: "); //$NON-NLS-1$
420 result
.append(manyValuedAttribute
);
422 return result
.toString();