| /** |
| * <copyright> |
| * </copyright> |
| * |
| * $Id: TraitImpl.java,v 1.1 2007/01/15 23:26:15 gkessler Exp $ |
| */ |
| package org.eclipse.jst.jsf.common.metadata.internal.impl; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.impl.EObjectImpl; |
| import org.eclipse.jst.jsf.common.metadata.internal.provisional.MetadataPackage; |
| import org.eclipse.jst.jsf.common.metadata.internal.provisional.Model; |
| import org.eclipse.jst.jsf.common.metadata.internal.provisional.Trait; |
| import org.eclipse.jst.jsf.common.metadata.internal.provisional.query.ITraitVisitor; |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Trait</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link com.foo.model.metadata.impl.TraitImpl#getType <em>Type</em>}</li> |
| * <li>{@link com.foo.model.metadata.impl.TraitImpl#getValue <em>Value</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| /** |
| * @author Owner |
| * |
| */ |
| public class TraitImpl extends EObjectImpl implements Trait { |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static final String copyright = "Copyright (c) 2007 Oracle Corporation"; |
| |
| /** |
| * The default value of the '{@link #getId() <em>Id</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getId() |
| * @generated |
| * @ordered |
| */ |
| protected static final String ID_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getId() <em>Id</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getId() |
| * @generated |
| * @ordered |
| */ |
| protected String id = ID_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getValue() <em>Value</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected EObject value = null; |
| |
| /** |
| * The cached value of the '{@link #getSourceModel() <em>Source Model</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSourceModel() |
| * @generated |
| * @ordered |
| */ |
| protected Model sourceModel = null; |
| |
| /** |
| * This is true if the Source Model reference has been set. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| protected boolean sourceModelESet = false; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TraitImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EClass eStaticClass() { |
| return MetadataPackage.Literals.TRAIT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EObject getValue() { |
| if (value != null && value.eIsProxy()) { |
| InternalEObject oldValue = (InternalEObject)value; |
| value = eResolveProxy(oldValue); |
| if (value != oldValue) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MetadataPackage.TRAIT__VALUE, oldValue, value)); |
| } |
| } |
| return value; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EObject basicGetValue() { |
| return value; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setValue(EObject newValue) { |
| EObject oldValue = value; |
| value = newValue; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__VALUE, oldValue, value)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Model getSourceModel() { |
| if (sourceModel != null && sourceModel.eIsProxy()) { |
| InternalEObject oldSourceModel = (InternalEObject)sourceModel; |
| sourceModel = (Model)eResolveProxy(oldSourceModel); |
| if (sourceModel != oldSourceModel) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MetadataPackage.TRAIT__SOURCE_MODEL, oldSourceModel, sourceModel)); |
| } |
| } |
| return sourceModel; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Model basicGetSourceModel() { |
| return sourceModel; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setSourceModel(Model newSourceModel) { |
| Model oldSourceModel = sourceModel; |
| sourceModel = newSourceModel; |
| boolean oldSourceModelESet = sourceModelESet; |
| sourceModelESet = true; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__SOURCE_MODEL, oldSourceModel, sourceModel, !oldSourceModelESet)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void unsetSourceModel() { |
| Model oldSourceModel = sourceModel; |
| boolean oldSourceModelESet = sourceModelESet; |
| sourceModel = null; |
| sourceModelESet = false; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.UNSET, MetadataPackage.TRAIT__SOURCE_MODEL, oldSourceModel, null, oldSourceModelESet)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetSourceModel() { |
| return sourceModelESet; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getId() { |
| return id; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setId(String newId) { |
| String oldId = id; |
| id = newId; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackage.TRAIT__ID, oldId, id)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public void accept(ITraitVisitor visitor) { |
| visitor.visit(this); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case MetadataPackage.TRAIT__ID: |
| return getId(); |
| case MetadataPackage.TRAIT__VALUE: |
| if (resolve) return getValue(); |
| return basicGetValue(); |
| case MetadataPackage.TRAIT__SOURCE_MODEL: |
| if (resolve) return getSourceModel(); |
| return basicGetSourceModel(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case MetadataPackage.TRAIT__ID: |
| setId((String)newValue); |
| return; |
| case MetadataPackage.TRAIT__VALUE: |
| setValue((EObject)newValue); |
| return; |
| case MetadataPackage.TRAIT__SOURCE_MODEL: |
| setSourceModel((Model)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MetadataPackage.TRAIT__ID: |
| setId(ID_EDEFAULT); |
| return; |
| case MetadataPackage.TRAIT__VALUE: |
| setValue((EObject)null); |
| return; |
| case MetadataPackage.TRAIT__SOURCE_MODEL: |
| unsetSourceModel(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MetadataPackage.TRAIT__ID: |
| return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); |
| case MetadataPackage.TRAIT__VALUE: |
| return value != null; |
| case MetadataPackage.TRAIT__SOURCE_MODEL: |
| return isSetSourceModel(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (id: "); |
| result.append(id); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| public boolean equals(Object value){ |
| if (!(value instanceof String)) |
| return super.equals(value); |
| |
| String key = (String)value; |
| if (key.equals(getId())) |
| return true; |
| |
| return false; |
| } |
| } //TraitImpl |