blob: ce3122ae9523913853cd7cc74bb5aa3ff0aeebe7 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 Oracle.
* 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:
* Oracle - initial API and implementation
*******************************************************************************/
package org.eclipse.jpt.core.resource.orm;
import java.util.Collection;
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.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jpt.core.internal.utility.translators.SimpleTranslator;
import org.eclipse.jpt.core.resource.orm.v2_0.JPA2_0;
import org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlCollectionTable_2_0;
import org.eclipse.wst.common.internal.emf.resource.Translator;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Xml Collection Table</b></em>'.
* <!-- end-user-doc -->
*
*
* @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlCollectionTable()
* @model kind="class"
* @generated
*/
public class XmlCollectionTable extends AbstractXmlTable implements XmlCollectionTable_2_0
{
/**
* The cached value of the '{@link #getJoinColumns() <em>Join Columns</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getJoinColumns()
* @generated
* @ordered
*/
protected EList<XmlJoinColumn> joinColumns;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected XmlCollectionTable()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return OrmPackage.Literals.XML_COLLECTION_TABLE;
}
/**
* Returns the value of the '<em><b>Join Columns</b></em>' containment reference list.
* The list contents are of type {@link org.eclipse.jpt.core.resource.orm.XmlJoinColumn}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Join Columns</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Join Columns</em>' containment reference list.
* @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlCollectionTable_2_0_JoinColumns()
* @model containment="true"
* @generated
*/
public EList<XmlJoinColumn> getJoinColumns()
{
if (joinColumns == null)
{
joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS);
}
return joinColumns;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS:
return ((InternalEList<?>)getJoinColumns()).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 OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS:
return getJoinColumns();
}
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 OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS:
getJoinColumns().clear();
getJoinColumns().addAll((Collection<? extends XmlJoinColumn>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS:
getJoinColumns().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS:
return joinColumns != null && !joinColumns.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass)
{
if (baseClass == XmlCollectionTable_2_0.class)
{
switch (derivedFeatureID)
{
case OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS: return OrmV2_0Package.XML_COLLECTION_TABLE_20__JOIN_COLUMNS;
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 == XmlCollectionTable_2_0.class)
{
switch (baseFeatureID)
{
case OrmV2_0Package.XML_COLLECTION_TABLE_20__JOIN_COLUMNS: return OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
// ********** translators **********
public static Translator buildTranslator(String elementName, EStructuralFeature structuralFeature) {
return new SimpleTranslator(elementName, structuralFeature, buildTranslatorChildren());
}
private static Translator[] buildTranslatorChildren() {
return new Translator[] {
buildNameTranslator(),
buildCatalogTranslator(),
buildSchemaTranslator(),
buildJoinColumnsTranslator(),
buildUniqueConstraintTranslator()
};
}
protected static Translator buildJoinColumnsTranslator() {
return XmlPrimaryKeyJoinColumn.buildTranslator(JPA2_0.JOIN_COLUMN, OrmV2_0Package.eINSTANCE.getXmlCollectionTable_2_0_JoinColumns());
}
}