/**
* <copyright>
* </copyright>
*
* $Id$
*/
package OntoUML.impl;
import OntoUML.Classifier;
import OntoUML.Generalization;
import OntoUML.OntoUMLPackage;
import OntoUML.Property;
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.EAnnotation;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.ocl.ParserException;
import org.eclipse.ocl.Query;
import org.eclipse.ocl.ecore.OCL;
import org.eclipse.ocl.ecore.OCL.Helper;
import org.eclipse.ocl.expressions.OCLExpression;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Classifier</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link OntoUML.impl.ClassifierImpl#getAttribute <em>Attribute</em>}</li>
* <li>{@link OntoUML.impl.ClassifierImpl#isIsAbstract <em>Is Abstract</em>}</li>
* <li>{@link OntoUML.impl.ClassifierImpl#getGeneral <em>General</em>}</li>
* <li>{@link OntoUML.impl.ClassifierImpl#getGeneralization <em>Generalization</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ClassifierImpl extends TypeImpl implements Classifier {
/**
* The default value of the '{@link #isIsAbstract() <em>Is Abstract</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsAbstract()
* @generated
* @ordered
*/
protected static final boolean IS_ABSTRACT_EDEFAULT = false;
/**
* The cached value of the '{@link #isIsAbstract() <em>Is Abstract</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsAbstract()
* @generated
* @ordered
*/
protected boolean isAbstract = IS_ABSTRACT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ClassifierImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return OntoUMLPackage.Literals.CLASSIFIER;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Property> getAttribute() {
EStructuralFeature eFeature = OntoUMLPackage.Literals.CLASSIFIER__ATTRIBUTE;
if (attributeDeriveOCL == null) {
Helper helper = OCL_ENV.createOCLHelper();
helper.setAttributeContext(OntoUMLPackage.Literals.CLASSIFIER, eFeature);
EAnnotation ocl = eFeature.getEAnnotation(OCL_ANNOTATION_SOURCE);
String derive = (String) ocl.getDetails().get("derive");
try {
attributeDeriveOCL = helper.createQuery(derive);
} catch (ParserException e) {
throw new UnsupportedOperationException(e.getLocalizedMessage());
}
}
Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(attributeDeriveOCL);
@SuppressWarnings("unchecked")
Collection<Property> result = (Collection<Property>) query.evaluate(this);
return new EcoreEList.UnmodifiableEList<Property>(this, eFeature, result.size(), result.toArray());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isIsAbstract() {
return isAbstract;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIsAbstract(boolean newIsAbstract) {
boolean oldIsAbstract = isAbstract;
isAbstract = newIsAbstract;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, OntoUMLPackage.CLASSIFIER__IS_ABSTRACT, oldIsAbstract, isAbstract));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Classifier> getGeneral() {
EStructuralFeature eFeature = OntoUMLPackage.Literals.CLASSIFIER__GENERAL;
if (generalDeriveOCL == null) {
Helper helper = OCL_ENV.createOCLHelper();
helper.setAttributeContext(OntoUMLPackage.Literals.CLASSIFIER, eFeature);
EAnnotation ocl = eFeature.getEAnnotation(OCL_ANNOTATION_SOURCE);
String derive = (String) ocl.getDetails().get("derive");
try {
generalDeriveOCL = helper.createQuery(derive);
} catch (ParserException e) {
throw new UnsupportedOperationException(e.getLocalizedMessage());
}
}
Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(generalDeriveOCL);
@SuppressWarnings("unchecked")
Collection<Classifier> result = (Collection<Classifier>) query.evaluate(this);
return new EcoreEList.UnmodifiableEList<Classifier>(this, eFeature, result.size(), result.toArray());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Generalization> getGeneralization() {
EStructuralFeature eFeature = OntoUMLPackage.Literals.CLASSIFIER__GENERALIZATION;
if (generalizationDeriveOCL == null) {
Helper helper = OCL_ENV.createOCLHelper();
helper.setAttributeContext(OntoUMLPackage.Literals.CLASSIFIER, eFeature);
EAnnotation ocl = eFeature.getEAnnotation(OCL_ANNOTATION_SOURCE);
String derive = (String) ocl.getDetails().get("derive");
try {
generalizationDeriveOCL = helper.createQuery(derive);
} catch (ParserException e) {
throw new UnsupportedOperationException(e.getLocalizedMessage());
}
}
Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(generalizationDeriveOCL);
@SuppressWarnings("unchecked")
Collection<Generalization> result = (Collection<Generalization>) query.evaluate(this);
return new EcoreEList.UnmodifiableEList<Generalization>(this, eFeature, result.size(), result.toArray());
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case OntoUMLPackage.CLASSIFIER__ATTRIBUTE:
return ((InternalEList<?>)getAttribute()).basicRemove(otherEnd, msgs);
case OntoUMLPackage.CLASSIFIER__GENERALIZATION:
return ((InternalEList<?>)getGeneralization()).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 OntoUMLPackage.CLASSIFIER__ATTRIBUTE:
return getAttribute();
case OntoUMLPackage.CLASSIFIER__IS_ABSTRACT:
return isIsAbstract() ? Boolean.TRUE : Boolean.FALSE;
case OntoUMLPackage.CLASSIFIER__GENERAL:
return getGeneral();
case OntoUMLPackage.CLASSIFIER__GENERALIZATION:
return getGeneralization();
}
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 OntoUMLPackage.CLASSIFIER__ATTRIBUTE:
getAttribute().clear();
getAttribute().addAll((Collection<? extends Property>)newValue);
return;
case OntoUMLPackage.CLASSIFIER__IS_ABSTRACT:
setIsAbstract(((Boolean)newValue).booleanValue());
return;
case OntoUMLPackage.CLASSIFIER__GENERAL:
getGeneral().clear();
getGeneral().addAll((Collection<? extends Classifier>)newValue);
return;
case OntoUMLPackage.CLASSIFIER__GENERALIZATION:
getGeneralization().clear();
getGeneralization().addAll((Collection<? extends Generalization>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case OntoUMLPackage.CLASSIFIER__ATTRIBUTE:
getAttribute().clear();
return;
case OntoUMLPackage.CLASSIFIER__IS_ABSTRACT:
setIsAbstract(IS_ABSTRACT_EDEFAULT);
return;
case OntoUMLPackage.CLASSIFIER__GENERAL:
getGeneral().clear();
return;
case OntoUMLPackage.CLASSIFIER__GENERALIZATION:
getGeneralization().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case OntoUMLPackage.CLASSIFIER__ATTRIBUTE:
return !getAttribute().isEmpty();
case OntoUMLPackage.CLASSIFIER__IS_ABSTRACT:
return isAbstract != IS_ABSTRACT_EDEFAULT;
case OntoUMLPackage.CLASSIFIER__GENERAL:
return !getGeneral().isEmpty();
case OntoUMLPackage.CLASSIFIER__GENERALIZATION:
return !getGeneralization().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(" (isAbstract: ");
result.append(isAbstract);
result.append(')');
return result.toString();
}
/**
* The parsed OCL expression for the derivation of '{@link #getAttribute <em>Attribute</em>}' property.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAttribute
* @generated
*/
private static OCLExpression<EClassifier> attributeDeriveOCL;
/**
* The parsed OCL expression for the derivation of '{@link #getGeneral <em>General</em>}' property.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getGeneral
* @generated
*/
private static OCLExpression<EClassifier> generalDeriveOCL;
/**
* The parsed OCL expression for the derivation of '{@link #getGeneralization <em>Generalization</em>}' property.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getGeneralization
* @generated
*/
private static OCLExpression<EClassifier> generalizationDeriveOCL;
private static final String OCL_ANNOTATION_SOURCE = "http://www.eclipse.org/ocl/examples/OCL";
private static final OCL OCL_ENV = OCL.newInstance();
} //ClassifierImpl