|
|
@@ -3,8 +3,12 @@
|
|
|
package org.yakindu.base.types.impl;
|
|
|
|
|
|
import java.util.Collection;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import org.eclipse.emf.common.notify.NotificationChain;
|
|
|
+import org.eclipse.emf.common.util.BasicEList;
|
|
|
import org.eclipse.emf.common.util.EList;
|
|
|
import org.eclipse.emf.ecore.EClass;
|
|
|
import org.eclipse.emf.ecore.InternalEObject;
|
|
|
@@ -13,27 +17,29 @@ import org.eclipse.emf.ecore.util.EObjectResolvingEList;
|
|
|
import org.eclipse.emf.ecore.util.InternalEList;
|
|
|
import org.yakindu.base.types.ComplexType;
|
|
|
import org.yakindu.base.types.Feature;
|
|
|
+import org.yakindu.base.types.Type;
|
|
|
import org.yakindu.base.types.TypesPackage;
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * An implementation of the model object '<em><b>Complex Type</b></em>'.
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> An implementation of the model object '
|
|
|
+ * <em><b>Complex Type</b></em>'. <!-- end-user-doc -->
|
|
|
* <p>
|
|
|
* The following features are implemented:
|
|
|
* <ul>
|
|
|
- * <li>{@link org.yakindu.base.types.impl.ComplexTypeImpl#getFeatures <em>Features</em>}</li>
|
|
|
- * <li>{@link org.yakindu.base.types.impl.ComplexTypeImpl#getSuperTypes <em>Super Types</em>}</li>
|
|
|
+ * <li>{@link org.yakindu.base.types.impl.ComplexTypeImpl#getFeatures <em>
|
|
|
+ * Features</em>}</li>
|
|
|
+ * <li>{@link org.yakindu.base.types.impl.ComplexTypeImpl#getSuperTypes <em>
|
|
|
+ * Super Types</em>}</li>
|
|
|
* </ul>
|
|
|
* </p>
|
|
|
- *
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
public class ComplexTypeImpl extends ParameterizedTypeImpl implements ComplexType {
|
|
|
/**
|
|
|
- * The cached value of the '{@link #getFeatures() <em>Features</em>}' containment reference list.
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * The cached value of the '{@link #getFeatures() <em>Features</em>}'
|
|
|
+ * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @see #getFeatures()
|
|
|
* @generated
|
|
|
* @ordered
|
|
|
@@ -41,9 +47,9 @@ public class ComplexTypeImpl extends ParameterizedTypeImpl implements ComplexTyp
|
|
|
protected EList<Feature> features;
|
|
|
|
|
|
/**
|
|
|
- * The cached value of the '{@link #getSuperTypes() <em>Super Types</em>}' reference list.
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * The cached value of the '{@link #getSuperTypes() <em>Super Types</em>}'
|
|
|
+ * reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @see #getSuperTypes()
|
|
|
* @generated
|
|
|
* @ordered
|
|
|
@@ -51,8 +57,8 @@ public class ComplexTypeImpl extends ParameterizedTypeImpl implements ComplexTyp
|
|
|
protected EList<ComplexType> superTypes;
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
protected ComplexTypeImpl() {
|
|
|
@@ -60,8 +66,8 @@ public class ComplexTypeImpl extends ParameterizedTypeImpl implements ComplexTyp
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -70,127 +76,157 @@ public class ComplexTypeImpl extends ParameterizedTypeImpl implements ComplexTyp
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
public EList<Feature> getFeatures() {
|
|
|
if (features == null) {
|
|
|
- features = new EObjectContainmentWithInverseEList<Feature>(Feature.class, this, TypesPackage.COMPLEX_TYPE__FEATURES, TypesPackage.FEATURE__OWNING_TYPE);
|
|
|
+ features = new EObjectContainmentWithInverseEList<Feature>(Feature.class, this,
|
|
|
+ TypesPackage.COMPLEX_TYPE__FEATURES, TypesPackage.FEATURE__OWNING_TYPE);
|
|
|
}
|
|
|
return features;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
public EList<ComplexType> getSuperTypes() {
|
|
|
if (superTypes == null) {
|
|
|
- superTypes = new EObjectResolvingEList<ComplexType>(ComplexType.class, this, TypesPackage.COMPLEX_TYPE__SUPER_TYPES);
|
|
|
+ superTypes = new EObjectResolvingEList<ComplexType>(ComplexType.class, this,
|
|
|
+ TypesPackage.COMPLEX_TYPE__SUPER_TYPES);
|
|
|
}
|
|
|
return superTypes;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
+ * @generated NOT
|
|
|
+ */
|
|
|
+ public EList<Feature> getAllFeatures() {
|
|
|
+ EList<Feature> features = new BasicEList<Feature>();
|
|
|
+ collectFeatures(this, features, new HashSet<Type>());
|
|
|
+ return features;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Performs a simple search to collect all features of the type and all
|
|
|
+ * super types.
|
|
|
+ *
|
|
|
+ */
|
|
|
+ protected void collectFeatures(Type type, List<Feature> features, Set<Type> visited) {
|
|
|
+ if (type == null || visited.contains(type))
|
|
|
+ return;
|
|
|
+ if (type instanceof ComplexType) {
|
|
|
+ for (Type superType : ((ComplexType) type).getSuperTypes()) {
|
|
|
+ collectFeatures(superType, features, visited);
|
|
|
+ }
|
|
|
+ features.addAll(((ComplexType) type).getFeatures());
|
|
|
+ }
|
|
|
+ visited.add(type);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
|
|
|
switch (featureID) {
|
|
|
- case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
- return ((InternalEList<InternalEObject>)(InternalEList<?>)getFeatures()).basicAdd(otherEnd, msgs);
|
|
|
+ case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
+ return ((InternalEList<InternalEObject>) (InternalEList<?>) getFeatures()).basicAdd(otherEnd, msgs);
|
|
|
}
|
|
|
return super.eInverseAdd(otherEnd, featureID, msgs);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@Override
|
|
|
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
|
|
|
switch (featureID) {
|
|
|
- case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
- return ((InternalEList<?>)getFeatures()).basicRemove(otherEnd, msgs);
|
|
|
+ case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
+ return ((InternalEList<?>) getFeatures()).basicRemove(otherEnd, msgs);
|
|
|
}
|
|
|
return super.eInverseRemove(otherEnd, featureID, msgs);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@Override
|
|
|
public Object eGet(int featureID, boolean resolve, boolean coreType) {
|
|
|
switch (featureID) {
|
|
|
- case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
- return getFeatures();
|
|
|
- case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
- return getSuperTypes();
|
|
|
+ case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
+ return getFeatures();
|
|
|
+ case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
+ return getSuperTypes();
|
|
|
}
|
|
|
return super.eGet(featureID, resolve, coreType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public void eSet(int featureID, Object newValue) {
|
|
|
switch (featureID) {
|
|
|
- case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
- getFeatures().clear();
|
|
|
- getFeatures().addAll((Collection<? extends Feature>)newValue);
|
|
|
- return;
|
|
|
- case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
- getSuperTypes().clear();
|
|
|
- getSuperTypes().addAll((Collection<? extends ComplexType>)newValue);
|
|
|
- return;
|
|
|
+ case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
+ getFeatures().clear();
|
|
|
+ getFeatures().addAll((Collection<? extends Feature>) newValue);
|
|
|
+ return;
|
|
|
+ case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
+ getSuperTypes().clear();
|
|
|
+ getSuperTypes().addAll((Collection<? extends ComplexType>) newValue);
|
|
|
+ return;
|
|
|
}
|
|
|
super.eSet(featureID, newValue);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@Override
|
|
|
public void eUnset(int featureID) {
|
|
|
switch (featureID) {
|
|
|
- case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
- getFeatures().clear();
|
|
|
- return;
|
|
|
- case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
- getSuperTypes().clear();
|
|
|
- return;
|
|
|
+ case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
+ getFeatures().clear();
|
|
|
+ return;
|
|
|
+ case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
+ getSuperTypes().clear();
|
|
|
+ return;
|
|
|
}
|
|
|
super.eUnset(featureID);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * <!-- begin-user-doc -->
|
|
|
- * <!-- end-user-doc -->
|
|
|
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
|
|
|
+ *
|
|
|
* @generated
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean eIsSet(int featureID) {
|
|
|
switch (featureID) {
|
|
|
- case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
- return features != null && !features.isEmpty();
|
|
|
- case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
- return superTypes != null && !superTypes.isEmpty();
|
|
|
+ case TypesPackage.COMPLEX_TYPE__FEATURES:
|
|
|
+ return features != null && !features.isEmpty();
|
|
|
+ case TypesPackage.COMPLEX_TYPE__SUPER_TYPES:
|
|
|
+ return superTypes != null && !superTypes.isEmpty();
|
|
|
}
|
|
|
return super.eIsSet(featureID);
|
|
|
}
|
|
|
|
|
|
-} //ComplexTypeImpl
|
|
|
+} // ComplexTypeImpl
|