/**
* Copyright (c) 2015 committers of YAKINDU and others.
* 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:
* committers of YAKINDU - initial API and implementation
*
*/
package org.yakindu.sct.model.sgen.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.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.yakindu.base.base.impl.NamedElementImpl;
import org.yakindu.sct.model.sgen.DeprecatableElement;
import org.yakindu.sct.model.sgen.FeatureParameter;
import org.yakindu.sct.model.sgen.FeatureType;
import org.yakindu.sct.model.sgen.FeatureTypeLibrary;
import org.yakindu.sct.model.sgen.SGenPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Feature Type</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.yakindu.sct.model.sgen.impl.FeatureTypeImpl#isDeprecated <em>Deprecated</em>}</li>
* <li>{@link org.yakindu.sct.model.sgen.impl.FeatureTypeImpl#getComment <em>Comment</em>}</li>
* <li>{@link org.yakindu.sct.model.sgen.impl.FeatureTypeImpl#getParameters <em>Parameters</em>}</li>
* <li>{@link org.yakindu.sct.model.sgen.impl.FeatureTypeImpl#getLibrary <em>Library</em>}</li>
* <li>{@link org.yakindu.sct.model.sgen.impl.FeatureTypeImpl#isOptional <em>Optional</em>}</li>
* </ul>
*
* @generated
*/
public class FeatureTypeImpl extends NamedElementImpl implements FeatureType {
/**
* The default value of the '{@link #isDeprecated() <em>Deprecated</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isDeprecated()
* @generated
* @ordered
*/
protected static final boolean DEPRECATED_EDEFAULT = false;
/**
* The cached value of the '{@link #isDeprecated() <em>Deprecated</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isDeprecated()
* @generated
* @ordered
*/
protected boolean deprecated = DEPRECATED_EDEFAULT;
/**
* The default value of the '{@link #getComment() <em>Comment</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getComment()
* @generated
* @ordered
*/
protected static final String COMMENT_EDEFAULT = null;
/**
* The cached value of the '{@link #getComment() <em>Comment</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getComment()
* @generated
* @ordered
*/
protected String comment = COMMENT_EDEFAULT;
/**
* The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParameters()
* @generated
* @ordered
*/
protected EList<FeatureParameter> parameters;
/**
* The default value of the '{@link #isOptional() <em>Optional</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isOptional()
* @generated
* @ordered
*/
protected static final boolean OPTIONAL_EDEFAULT = false;
/**
* The cached value of the '{@link #isOptional() <em>Optional</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isOptional()
* @generated
* @ordered
*/
protected boolean optional = OPTIONAL_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected FeatureTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return SGenPackage.Literals.FEATURE_TYPE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isDeprecated() {
return deprecated;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDeprecated(boolean newDeprecated) {
boolean oldDeprecated = deprecated;
deprecated = newDeprecated;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SGenPackage.FEATURE_TYPE__DEPRECATED, oldDeprecated, deprecated));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getComment() {
return comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setComment(String newComment) {
String oldComment = comment;
comment = newComment;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SGenPackage.FEATURE_TYPE__COMMENT, oldComment, comment));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<FeatureParameter> getParameters() {
if (parameters == null) {
parameters = new EObjectContainmentWithInverseEList<FeatureParameter>(FeatureParameter.class, this, SGenPackage.FEATURE_TYPE__PARAMETERS, SGenPackage.FEATURE_PARAMETER__FEATURE_TYPE);
}
return parameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public FeatureTypeLibrary getLibrary() {
FeatureTypeLibrary library = basicGetLibrary();
return library != null && library.eIsProxy() ? (FeatureTypeLibrary)eResolveProxy((InternalEObject)library) : library;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public FeatureTypeLibrary basicGetLibrary() {
return (FeatureTypeLibrary) eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isOptional() {
return optional;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOptional(boolean newOptional) {
boolean oldOptional = optional;
optional = newOptional;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SGenPackage.FEATURE_TYPE__OPTIONAL, oldOptional, optional));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case SGenPackage.FEATURE_TYPE__PARAMETERS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getParameters()).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 SGenPackage.FEATURE_TYPE__PARAMETERS:
return ((InternalEList<?>)getParameters()).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 SGenPackage.FEATURE_TYPE__DEPRECATED:
return isDeprecated();
case SGenPackage.FEATURE_TYPE__COMMENT:
return getComment();
case SGenPackage.FEATURE_TYPE__PARAMETERS:
return getParameters();
case SGenPackage.FEATURE_TYPE__LIBRARY:
if (resolve) return getLibrary();
return basicGetLibrary();
case SGenPackage.FEATURE_TYPE__OPTIONAL:
return isOptional();
}
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 SGenPackage.FEATURE_TYPE__DEPRECATED:
setDeprecated((Boolean)newValue);
return;
case SGenPackage.FEATURE_TYPE__COMMENT:
setComment((String)newValue);
return;
case SGenPackage.FEATURE_TYPE__PARAMETERS:
getParameters().clear();
getParameters().addAll((Collection<? extends FeatureParameter>)newValue);
return;
case SGenPackage.FEATURE_TYPE__OPTIONAL:
setOptional((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case SGenPackage.FEATURE_TYPE__DEPRECATED:
setDeprecated(DEPRECATED_EDEFAULT);
return;
case SGenPackage.FEATURE_TYPE__COMMENT:
setComment(COMMENT_EDEFAULT);
return;
case SGenPackage.FEATURE_TYPE__PARAMETERS:
getParameters().clear();
return;
case SGenPackage.FEATURE_TYPE__OPTIONAL:
setOptional(OPTIONAL_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case SGenPackage.FEATURE_TYPE__DEPRECATED:
return deprecated != DEPRECATED_EDEFAULT;
case SGenPackage.FEATURE_TYPE__COMMENT:
return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment);
case SGenPackage.FEATURE_TYPE__PARAMETERS:
return parameters != null && !parameters.isEmpty();
case SGenPackage.FEATURE_TYPE__LIBRARY:
return basicGetLibrary() != null;
case SGenPackage.FEATURE_TYPE__OPTIONAL:
return optional != OPTIONAL_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == DeprecatableElement.class) {
switch (derivedFeatureID) {
case SGenPackage.FEATURE_TYPE__DEPRECATED: return SGenPackage.DEPRECATABLE_ELEMENT__DEPRECATED;
case SGenPackage.FEATURE_TYPE__COMMENT: return SGenPackage.DEPRECATABLE_ELEMENT__COMMENT;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
if (baseClass == DeprecatableElement.class) {
switch (baseFeatureID) {
case SGenPackage.DEPRECATABLE_ELEMENT__DEPRECATED: return SGenPackage.FEATURE_TYPE__DEPRECATED;
case SGenPackage.DEPRECATABLE_ELEMENT__COMMENT: return SGenPackage.FEATURE_TYPE__COMMENT;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (deprecated: ");
result.append(deprecated);
result.append(", comment: ");
result.append(comment);
result.append(", optional: ");
result.append(optional);
result.append(')');
return result.toString();
}
} //FeatureTypeImpl