diff options
Diffstat (limited to 'core/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pannotation/impl/OneToOneImpl.java')
-rwxr-xr-x | core/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pannotation/impl/OneToOneImpl.java | 397 |
1 files changed, 397 insertions, 0 deletions
diff --git a/core/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pannotation/impl/OneToOneImpl.java b/core/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pannotation/impl/OneToOneImpl.java new file mode 100755 index 000000000..b6141937a --- /dev/null +++ b/core/org.eclipse.emf.teneo.annotations/src/org/eclipse/emf/teneo/annotations/pannotation/impl/OneToOneImpl.java @@ -0,0 +1,397 @@ +/** + * <copyright> + * </copyright> + * + * $Id: OneToOneImpl.java,v 1.9 2009/06/11 04:59:34 mtaal Exp $ + */ +package org.eclipse.emf.teneo.annotations.pannotation.impl; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; +import org.eclipse.emf.teneo.annotations.pannotation.CascadeType; +import org.eclipse.emf.teneo.annotations.pannotation.FetchType; +import org.eclipse.emf.teneo.annotations.pannotation.OneToOne; +import org.eclipse.emf.teneo.annotations.pannotation.PannotationPackage; + +/** + * <!-- begin-user-doc --> An implementation of the model object '<em><b>One To One</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.teneo.annotations.pannotation.impl.OneToOneImpl#getTargetEntity <em>Target Entity</em>}</li> + * <li>{@link org.eclipse.emf.teneo.annotations.pannotation.impl.OneToOneImpl#getCascade <em>Cascade</em>}</li> + * <li>{@link org.eclipse.emf.teneo.annotations.pannotation.impl.OneToOneImpl#getFetch <em>Fetch</em>}</li> + * <li>{@link org.eclipse.emf.teneo.annotations.pannotation.impl.OneToOneImpl#isOptional <em>Optional</em>}</li> + * <li>{@link org.eclipse.emf.teneo.annotations.pannotation.impl.OneToOneImpl#getMappedBy <em>Mapped By</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class OneToOneImpl extends PAnnotationImpl implements OneToOne { + /** + * The default value of the '{@link #getTargetEntity() <em>Target Entity</em>}' attribute. + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @see #getTargetEntity() + * @generated + * @ordered + */ + protected static final String TARGET_ENTITY_EDEFAULT = null; + + /** + * The cached value of the '{@link #getTargetEntity() <em>Target Entity</em>}' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see #getTargetEntity() + * @generated + * @ordered + */ + protected String targetEntity = TARGET_ENTITY_EDEFAULT; + + /** + * The cached value of the '{@link #getCascade() <em>Cascade</em>}' attribute list. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see #getCascade() + * @generated + * @ordered + */ + protected EList<CascadeType> cascade; + + /** + * The default value of the '{@link #getFetch() <em>Fetch</em>}' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see #getFetch() + * @generated + * @ordered + */ + protected static final FetchType FETCH_EDEFAULT = FetchType.EAGER; + + /** + * The cached value of the '{@link #getFetch() <em>Fetch</em>}' attribute. + * <!-- begin-user-doc + * --> <!-- end-user-doc --> + * @see #getFetch() + * @generated + * @ordered + */ + protected FetchType fetch = FETCH_EDEFAULT; + + /** + * This is true if the Fetch attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean fetchESet; + + /** + * 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 = true; + + /** + * 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; + + /** + * The default value of the '{@link #getMappedBy() <em>Mapped By</em>}' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see #getMappedBy() + * @generated + * @ordered + */ + protected static final String MAPPED_BY_EDEFAULT = null; + + /** + * The cached value of the '{@link #getMappedBy() <em>Mapped By</em>}' attribute. <!-- + * begin-user-doc --> <!-- end-user-doc --> + * + * @see #getMappedBy() + * @generated + * @ordered + */ + protected String mappedBy = MAPPED_BY_EDEFAULT; + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + protected OneToOneImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + @Override + protected EClass eStaticClass() { + return PannotationPackage.Literals.ONE_TO_ONE; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public FetchType getFetch() { + return fetch; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public void setFetch(FetchType newFetch) { + FetchType oldFetch = fetch; + fetch = newFetch == null ? FETCH_EDEFAULT : newFetch; + boolean oldFetchESet = fetchESet; + fetchESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PannotationPackage.ONE_TO_ONE__FETCH, oldFetch, fetch, !oldFetchESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetFetch() { + FetchType oldFetch = fetch; + boolean oldFetchESet = fetchESet; + fetch = FETCH_EDEFAULT; + fetchESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, PannotationPackage.ONE_TO_ONE__FETCH, oldFetch, FETCH_EDEFAULT, oldFetchESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetFetch() { + return fetchESet; + } + + /** + * <!-- 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, PannotationPackage.ONE_TO_ONE__OPTIONAL, oldOptional, optional)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public String getTargetEntity() { + return targetEntity; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public void setTargetEntity(String newTargetEntity) { + String oldTargetEntity = targetEntity; + targetEntity = newTargetEntity; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PannotationPackage.ONE_TO_ONE__TARGET_ENTITY, oldTargetEntity, targetEntity)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public EList<CascadeType> getCascade() { + if (cascade == null) { + cascade = new EDataTypeUniqueEList<CascadeType>(CascadeType.class, this, PannotationPackage.ONE_TO_ONE__CASCADE); + } + return cascade; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public String getMappedBy() { + return mappedBy; + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + public void setMappedBy(String newMappedBy) { + String oldMappedBy = mappedBy; + mappedBy = newMappedBy; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PannotationPackage.ONE_TO_ONE__MAPPED_BY, oldMappedBy, mappedBy)); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PannotationPackage.ONE_TO_ONE__TARGET_ENTITY: + return getTargetEntity(); + case PannotationPackage.ONE_TO_ONE__CASCADE: + return getCascade(); + case PannotationPackage.ONE_TO_ONE__FETCH: + return getFetch(); + case PannotationPackage.ONE_TO_ONE__OPTIONAL: + return isOptional(); + case PannotationPackage.ONE_TO_ONE__MAPPED_BY: + return getMappedBy(); + } + 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 PannotationPackage.ONE_TO_ONE__TARGET_ENTITY: + setTargetEntity((String)newValue); + return; + case PannotationPackage.ONE_TO_ONE__CASCADE: + getCascade().clear(); + getCascade().addAll((Collection<? extends CascadeType>)newValue); + return; + case PannotationPackage.ONE_TO_ONE__FETCH: + setFetch((FetchType)newValue); + return; + case PannotationPackage.ONE_TO_ONE__OPTIONAL: + setOptional((Boolean)newValue); + return; + case PannotationPackage.ONE_TO_ONE__MAPPED_BY: + setMappedBy((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PannotationPackage.ONE_TO_ONE__TARGET_ENTITY: + setTargetEntity(TARGET_ENTITY_EDEFAULT); + return; + case PannotationPackage.ONE_TO_ONE__CASCADE: + getCascade().clear(); + return; + case PannotationPackage.ONE_TO_ONE__FETCH: + unsetFetch(); + return; + case PannotationPackage.ONE_TO_ONE__OPTIONAL: + setOptional(OPTIONAL_EDEFAULT); + return; + case PannotationPackage.ONE_TO_ONE__MAPPED_BY: + setMappedBy(MAPPED_BY_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PannotationPackage.ONE_TO_ONE__TARGET_ENTITY: + return TARGET_ENTITY_EDEFAULT == null ? targetEntity != null : !TARGET_ENTITY_EDEFAULT.equals(targetEntity); + case PannotationPackage.ONE_TO_ONE__CASCADE: + return cascade != null && !cascade.isEmpty(); + case PannotationPackage.ONE_TO_ONE__FETCH: + return isSetFetch(); + case PannotationPackage.ONE_TO_ONE__OPTIONAL: + return optional != OPTIONAL_EDEFAULT; + case PannotationPackage.ONE_TO_ONE__MAPPED_BY: + return MAPPED_BY_EDEFAULT == null ? mappedBy != null : !MAPPED_BY_EDEFAULT.equals(mappedBy); + } + 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(" (targetEntity: "); + result.append(targetEntity); + result.append(", cascade: "); + result.append(cascade); + result.append(", fetch: "); + if (fetchESet) result.append(fetch); else result.append("<unset>"); + result.append(", optional: "); + result.append(optional); + result.append(", mappedBy: "); + result.append(mappedBy); + result.append(')'); + return result.toString(); + } + + @Override + protected String getAnnotationValue(org.eclipse.emf.ecore.EObject eObject, EStructuralFeature eFeature, + boolean prependComma, List<String> imports) { + if (eFeature == PannotationPackage.eINSTANCE.getOneToOne_TargetEntity()) { + // do not return anything because jpa expects a real classname, + // the targetentity only has an entityname here. + return ""; + } + return super.getAnnotationValue(eObject, eFeature, prependComma, imports); + } + +} // OneToOneImpl |