/******************************************************************************* * Copyright (c) 2013 hangum. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * hangum - initial API and implementation ******************************************************************************/ /** */ package com.hangum.tadpole.mongodb.model.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.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EObjectResolvingEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; import com.hangum.tadpole.mongodb.model.Column; import com.hangum.tadpole.mongodb.model.DB; import com.hangum.tadpole.mongodb.model.MongodbPackage; import com.hangum.tadpole.mongodb.model.Table; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Column</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getField <em>Field</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getType <em>Type</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getDefault <em>Default</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getTable <em>Table</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getLogicalField <em>Logical Field</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getKey <em>Key</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getComment <em>Comment</em>}</li> * <li>{@link com.hangum.tadpole.mongodb.model.impl.ColumnImpl#getSubDoc <em>Sub Doc</em>}</li> * </ul> * </p> * * @generated */ public class ColumnImpl extends EObjectImpl implements Column { /** * The default value of the '{@link #getField() <em>Field</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getField() * @generated * @ordered */ protected static final String FIELD_EDEFAULT = null; /** * The cached value of the '{@link #getField() <em>Field</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getField() * @generated * @ordered */ protected String field = FIELD_EDEFAULT; /** * The default value of the '{@link #getType() <em>Type</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getType() * @generated * @ordered */ protected static final String TYPE_EDEFAULT = null; /** * The cached value of the '{@link #getType() <em>Type</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getType() * @generated * @ordered */ protected String type = TYPE_EDEFAULT; /** * The default value of the '{@link #getDefault() <em>Default</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDefault() * @generated * @ordered */ protected static final String DEFAULT_EDEFAULT = null; /** * The cached value of the '{@link #getDefault() <em>Default</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDefault() * @generated * @ordered */ protected String default_ = DEFAULT_EDEFAULT; /** * The default value of the '{@link #getLogicalField() <em>Logical Field</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLogicalField() * @generated * @ordered */ protected static final String LOGICAL_FIELD_EDEFAULT = null; /** * The cached value of the '{@link #getLogicalField() <em>Logical Field</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLogicalField() * @generated * @ordered */ protected String logicalField = LOGICAL_FIELD_EDEFAULT; /** * The default value of the '{@link #getKey() <em>Key</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getKey() * @generated * @ordered */ protected static final String KEY_EDEFAULT = null; /** * The cached value of the '{@link #getKey() <em>Key</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getKey() * @generated * @ordered */ protected String key = KEY_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 #getSubDoc() <em>Sub Doc</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getSubDoc() * @generated * @ordered */ protected EList<Column> subDoc; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ColumnImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return MongodbPackage.Literals.COLUMN; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getField() { return field; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setField(String newField) { String oldField = field; field = newField; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MongodbPackage.COLUMN__FIELD, oldField, field)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getType() { return type; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setType(String newType) { String oldType = type; type = newType; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MongodbPackage.COLUMN__TYPE, oldType, type)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getDefault() { return default_; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setDefault(String newDefault) { String oldDefault = default_; default_ = newDefault; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MongodbPackage.COLUMN__DEFAULT, oldDefault, default_)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Table getTable() { if (eContainerFeatureID() != MongodbPackage.COLUMN__TABLE) return null; return (Table)eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTable(Table newTable, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newTable, MongodbPackage.COLUMN__TABLE, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTable(Table newTable) { if (newTable != eInternalContainer() || (eContainerFeatureID() != MongodbPackage.COLUMN__TABLE && newTable != null)) { if (EcoreUtil.isAncestor(this, newTable)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newTable != null) msgs = ((InternalEObject)newTable).eInverseAdd(this, MongodbPackage.TABLE__COLUMNS, Table.class, msgs); msgs = basicSetTable(newTable, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MongodbPackage.COLUMN__TABLE, newTable, newTable)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getLogicalField() { return logicalField; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setLogicalField(String newLogicalField) { String oldLogicalField = logicalField; logicalField = newLogicalField; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MongodbPackage.COLUMN__LOGICAL_FIELD, oldLogicalField, logicalField)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getKey() { return key; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setKey(String newKey) { String oldKey = key; key = newKey; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, MongodbPackage.COLUMN__KEY, oldKey, key)); } /** * <!-- 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, MongodbPackage.COLUMN__COMMENT, oldComment, comment)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Column> getSubDoc() { if (subDoc == null) { subDoc = new EObjectContainmentEList<Column>(Column.class, this, MongodbPackage.COLUMN__SUB_DOC); } return subDoc; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case MongodbPackage.COLUMN__TABLE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetTable((Table)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 MongodbPackage.COLUMN__TABLE: return basicSetTable(null, msgs); case MongodbPackage.COLUMN__SUB_DOC: return ((InternalEList<?>)getSubDoc()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case MongodbPackage.COLUMN__TABLE: return eInternalContainer().eInverseRemove(this, MongodbPackage.TABLE__COLUMNS, Table.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case MongodbPackage.COLUMN__FIELD: return getField(); case MongodbPackage.COLUMN__TYPE: return getType(); case MongodbPackage.COLUMN__DEFAULT: return getDefault(); case MongodbPackage.COLUMN__TABLE: return getTable(); case MongodbPackage.COLUMN__LOGICAL_FIELD: return getLogicalField(); case MongodbPackage.COLUMN__KEY: return getKey(); case MongodbPackage.COLUMN__COMMENT: return getComment(); case MongodbPackage.COLUMN__SUB_DOC: return getSubDoc(); } 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 MongodbPackage.COLUMN__FIELD: setField((String)newValue); return; case MongodbPackage.COLUMN__TYPE: setType((String)newValue); return; case MongodbPackage.COLUMN__DEFAULT: setDefault((String)newValue); return; case MongodbPackage.COLUMN__TABLE: setTable((Table)newValue); return; case MongodbPackage.COLUMN__LOGICAL_FIELD: setLogicalField((String)newValue); return; case MongodbPackage.COLUMN__KEY: setKey((String)newValue); return; case MongodbPackage.COLUMN__COMMENT: setComment((String)newValue); return; case MongodbPackage.COLUMN__SUB_DOC: getSubDoc().clear(); getSubDoc().addAll((Collection<? extends Column>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case MongodbPackage.COLUMN__FIELD: setField(FIELD_EDEFAULT); return; case MongodbPackage.COLUMN__TYPE: setType(TYPE_EDEFAULT); return; case MongodbPackage.COLUMN__DEFAULT: setDefault(DEFAULT_EDEFAULT); return; case MongodbPackage.COLUMN__TABLE: setTable((Table)null); return; case MongodbPackage.COLUMN__LOGICAL_FIELD: setLogicalField(LOGICAL_FIELD_EDEFAULT); return; case MongodbPackage.COLUMN__KEY: setKey(KEY_EDEFAULT); return; case MongodbPackage.COLUMN__COMMENT: setComment(COMMENT_EDEFAULT); return; case MongodbPackage.COLUMN__SUB_DOC: getSubDoc().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case MongodbPackage.COLUMN__FIELD: return FIELD_EDEFAULT == null ? field != null : !FIELD_EDEFAULT.equals(field); case MongodbPackage.COLUMN__TYPE: return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type); case MongodbPackage.COLUMN__DEFAULT: return DEFAULT_EDEFAULT == null ? default_ != null : !DEFAULT_EDEFAULT.equals(default_); case MongodbPackage.COLUMN__TABLE: return getTable() != null; case MongodbPackage.COLUMN__LOGICAL_FIELD: return LOGICAL_FIELD_EDEFAULT == null ? logicalField != null : !LOGICAL_FIELD_EDEFAULT.equals(logicalField); case MongodbPackage.COLUMN__KEY: return KEY_EDEFAULT == null ? key != null : !KEY_EDEFAULT.equals(key); case MongodbPackage.COLUMN__COMMENT: return COMMENT_EDEFAULT == null ? comment != null : !COMMENT_EDEFAULT.equals(comment); case MongodbPackage.COLUMN__SUB_DOC: return subDoc != null && !subDoc.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(" (field: "); result.append(field); result.append(", type: "); result.append(type); result.append(", default: "); result.append(default_); result.append(", logicalField: "); result.append(logicalField); result.append(", key: "); result.append(key); result.append(", comment: "); result.append(comment); result.append(')'); return result.toString(); } } //ColumnImpl