/*******************************************************************************
* Copyright (c) 2007, 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.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.EDataTypeEList;
import org.eclipse.jpt.core.internal.utility.translators.SimpleTranslator;
import org.eclipse.jpt.core.resource.orm.v2_0.OrmV2_0Package;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlUniqueConstraint_2_0;
import org.eclipse.jpt.core.resource.xml.AbstractJpaEObject;
import org.eclipse.wst.common.internal.emf.resource.Translator;
/**
*
* A representation of the model object 'Unique Constraint'.
*
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
* stability. It is available at this early stage to solicit feedback from
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
*
*
* The following features are supported:
*
* - {@link org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint#getColumnNames Column Names}
*
*
*
* @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlUniqueConstraint()
* @model kind="class"
* @generated
*/
public class XmlUniqueConstraint extends AbstractJpaEObject implements XmlUniqueConstraint_2_0
{
/**
* The default value of the '{@link #getName() Name}' attribute.
*
*
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() Name}' attribute.
*
*
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getColumnNames() Column Names}' attribute list.
*
*
* @see #getColumnNames()
* @generated
* @ordered
*/
protected EList columnNames;
/**
*
*
* @generated
*/
protected XmlUniqueConstraint()
{
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass()
{
return OrmPackage.Literals.XML_UNIQUE_CONSTRAINT;
}
/**
* Returns the value of the 'Name' attribute.
*
*
* If the meaning of the 'Name' attribute isn't clear,
* there really should be more of a description here...
*
*
* @return the value of the 'Name' attribute.
* @see #setName(String)
* @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlUniqueConstraint_2_0_Name()
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
* @generated
*/
public String getName()
{
return name;
}
/**
* Sets the value of the '{@link org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint#getName Name}' attribute.
*
*
* @param value the new value of the 'Name' attribute.
* @see #getName()
* @generated
*/
public void setName(String newName)
{
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_UNIQUE_CONSTRAINT__NAME, oldName, name));
}
/**
* Returns the value of the 'Column Names' attribute list.
* The list contents are of type {@link java.lang.String}.
*
*
* If the meaning of the 'Column Names' attribute list isn't clear,
* there really should be more of a description here...
*
*
* @return the value of the 'Column Names' attribute list.
* @see org.eclipse.jpt.core.resource.orm.OrmPackage#getXmlUniqueConstraint_ColumnNames()
* @model unique="false" dataType="org.eclipse.emf.ecore.xml.type.String" required="true"
* @generated
*/
public EList getColumnNames()
{
if (columnNames == null)
{
columnNames = new EDataTypeEList(String.class, this, OrmPackage.XML_UNIQUE_CONSTRAINT__COLUMN_NAMES);
}
return columnNames;
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case OrmPackage.XML_UNIQUE_CONSTRAINT__NAME:
return getName();
case OrmPackage.XML_UNIQUE_CONSTRAINT__COLUMN_NAMES:
return getColumnNames();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case OrmPackage.XML_UNIQUE_CONSTRAINT__NAME:
setName((String)newValue);
return;
case OrmPackage.XML_UNIQUE_CONSTRAINT__COLUMN_NAMES:
getColumnNames().clear();
getColumnNames().addAll((Collection extends String>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case OrmPackage.XML_UNIQUE_CONSTRAINT__NAME:
setName(NAME_EDEFAULT);
return;
case OrmPackage.XML_UNIQUE_CONSTRAINT__COLUMN_NAMES:
getColumnNames().clear();
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case OrmPackage.XML_UNIQUE_CONSTRAINT__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case OrmPackage.XML_UNIQUE_CONSTRAINT__COLUMN_NAMES:
return columnNames != null && !columnNames.isEmpty();
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public String toString()
{
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (name: ");
result.append(name);
result.append(", columnNames: ");
result.append(columnNames);
result.append(')');
return result.toString();
}
// ********** translators **********
public static Translator buildTranslator(String elementName, EStructuralFeature structuralFeature) {
return new SimpleTranslator(elementName, structuralFeature, buildTranslatorChildren());
}
private static Translator[] buildTranslatorChildren() {
return new Translator[] {
buildNameTranslator(),
buildColumnNameTranslator(),
};
}
protected static Translator buildNameTranslator() {
return new Translator(JPA.NAME, OrmV2_0Package.eINSTANCE.getXmlUniqueConstraint_2_0_Name(), Translator.DOM_ATTRIBUTE);
}
protected static Translator buildColumnNameTranslator() {
return new Translator(JPA.COLUMN_NAME, OrmPackage.eINSTANCE.getXmlUniqueConstraint_ColumnNames());
}
}