/** | |
* ******************************************************************************* | |
* Copyright (c) 2008 Castor Technologies Inc. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* Alain Picard (Castor Technologies Inc) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.omg.smm.impl; | |
import java.util.Collection; | |
import org.eclipse.emf.common.notify.Notification; | |
import org.eclipse.emf.common.notify.NotificationChain; | |
import org.eclipse.emf.common.util.EList; | |
import org.eclipse.emf.ecore.EClass; | |
import org.eclipse.emf.ecore.InternalEObject; | |
import org.eclipse.emf.ecore.impl.ENotificationImpl; | |
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
import org.eclipse.gmt.modisco.omg.smm.Characteristic; | |
import org.eclipse.gmt.modisco.omg.smm.Measure; | |
import org.eclipse.gmt.modisco.omg.smm.SmmPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Characteristic</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.CharacteristicImpl#getName <em>Name</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.CharacteristicImpl#getParent <em>Parent</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.omg.smm.impl.CharacteristicImpl#getCharacteristics <em>Characteristics</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class CharacteristicImpl extends SmmElementImpl implements Characteristic { | |
/** | |
* The default value of the '{@link #getName() <em>Name</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getName() | |
* @generated | |
* @ordered | |
*/ | |
protected static final String NAME_EDEFAULT = null; | |
/** | |
* The cached value of the '{@link #getName() <em>Name</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getName() | |
* @generated | |
* @ordered | |
*/ | |
protected String name = NAME_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getParent() <em>Parent</em>}' reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getParent() | |
* @generated | |
* @ordered | |
*/ | |
protected Characteristic parent; | |
/** | |
* The cached value of the '{@link #getCharacteristics() <em>Characteristics</em>}' reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getCharacteristics() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Measure> characteristics; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected CharacteristicImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return SmmPackage.Literals.CHARACTERISTIC; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public String getName() { | |
return name; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setName(String newName) { | |
String oldName = name; | |
name = newName; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.CHARACTERISTIC__NAME, oldName, name)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Characteristic getParent() { | |
if (parent != null && parent.eIsProxy()) { | |
InternalEObject oldParent = (InternalEObject)parent; | |
parent = (Characteristic)eResolveProxy(oldParent); | |
if (parent != oldParent) { | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.RESOLVE, SmmPackage.CHARACTERISTIC__PARENT, oldParent, parent)); | |
} | |
} | |
return parent; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Characteristic basicGetParent() { | |
return parent; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setParent(Characteristic newParent) { | |
Characteristic oldParent = parent; | |
parent = newParent; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, SmmPackage.CHARACTERISTIC__PARENT, oldParent, parent)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Measure> getCharacteristics() { | |
if (characteristics == null) { | |
characteristics = new EObjectWithInverseResolvingEList<Measure>(Measure.class, this, SmmPackage.CHARACTERISTIC__CHARACTERISTICS, SmmPackage.MEASURE__TRAIT); | |
} | |
return characteristics; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case SmmPackage.CHARACTERISTIC__CHARACTERISTICS: | |
return ((InternalEList<InternalEObject>)(InternalEList<?>)getCharacteristics()).basicAdd(otherEnd, msgs); | |
} | |
return super.eInverseAdd(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case SmmPackage.CHARACTERISTIC__CHARACTERISTICS: | |
return ((InternalEList<?>)getCharacteristics()).basicRemove(otherEnd, msgs); | |
} | |
return super.eInverseRemove(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public Object eGet(int featureID, boolean resolve, boolean coreType) { | |
switch (featureID) { | |
case SmmPackage.CHARACTERISTIC__NAME: | |
return getName(); | |
case SmmPackage.CHARACTERISTIC__PARENT: | |
if (resolve) return getParent(); | |
return basicGetParent(); | |
case SmmPackage.CHARACTERISTIC__CHARACTERISTICS: | |
return getCharacteristics(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case SmmPackage.CHARACTERISTIC__NAME: | |
setName((String)newValue); | |
return; | |
case SmmPackage.CHARACTERISTIC__PARENT: | |
setParent((Characteristic)newValue); | |
return; | |
case SmmPackage.CHARACTERISTIC__CHARACTERISTICS: | |
getCharacteristics().clear(); | |
getCharacteristics().addAll((Collection<? extends Measure>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case SmmPackage.CHARACTERISTIC__NAME: | |
setName(NAME_EDEFAULT); | |
return; | |
case SmmPackage.CHARACTERISTIC__PARENT: | |
setParent((Characteristic)null); | |
return; | |
case SmmPackage.CHARACTERISTIC__CHARACTERISTICS: | |
getCharacteristics().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case SmmPackage.CHARACTERISTIC__NAME: | |
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); | |
case SmmPackage.CHARACTERISTIC__PARENT: | |
return parent != null; | |
case SmmPackage.CHARACTERISTIC__CHARACTERISTICS: | |
return characteristics != null && !characteristics.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public String toString() { | |
if (eIsProxy()) return super.toString(); | |
StringBuffer result = new StringBuffer(super.toString()); | |
result.append(" (name: "); //$NON-NLS-1$ | |
result.append(name); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //CharacteristicImpl |