public EGenericType getBoundGenericType(EGenericType genericType, EClass context) { ETypeParameter typeParameter = genericType.getETypeParameter(); if (typeParameter != null) { // the reference type is a type parameter TypeBindingAcceptor typeBindingAcceptor = new TypeBindingAcceptor(); addTypeParameterBindingsRecursively(context, typeBindingAcceptor); return typeBindingAcceptor.getBoundGenericType(typeParameter); } else { // the reference type is a generic type if (genericType.getEClassifier() == null) { throw new IllegalStateException("Either typeParameter or eRawType must be set in EGenericType " + genericType); } return genericType; } }
protected static void addTypeParameterBindingsRecursively(EClass context, TypeBindingAcceptor bindingAcceptor) { for (EGenericType genericSuperType : context.getEGenericSuperTypes()) { EClassifier rawSuperType = genericSuperType.getEClassifier(); EList<EGenericType> typeArguments = genericSuperType.getETypeArguments(); EList<ETypeParameter> typeParameters = rawSuperType.getETypeParameters(); if (typeArguments.size() != typeParameters.size()) { throw new IllegalStateException( "Number of typeArguments does not match number of typeParameters in EGenericType " + genericSuperType); } for (int i = 0; i < typeArguments.size(); ++i) { bindingAcceptor.accept(typeParameters.get(i), typeArguments.get(i)); } if (rawSuperType instanceof EClass) { addTypeParameterBindingsRecursively((EClass) rawSuperType, bindingAcceptor); } } }
public void accept(ETypeParameter typeParameter, EGenericType typeArgument) { if(bindings==null) { bindings = new HashMap<ETypeParameter, EGenericType>(); } ETypeParameter replacedParameter = typeArgument.getETypeParameter(); if (replacedParameter != null) { EGenericType existingBoundType = bindings.get(replacedParameter); if (existingBoundType != null) { bindings.remove(replacedParameter); bindings.put(typeParameter, existingBoundType); return; } } else { if (typeArgument.getEClassifier() == null) { throw new IllegalStateException("Either typeParameter or eClassifier must be set in ETypeArgument " + typeArgument); } } bindings.put(typeParameter, typeArgument); }
@Override protected void applyTyped(UMLReferencingElement<Element> object) { QualifiedName qn = qualifiedNameProvider.getFullyQualifiedName(object); if (qn == null) { return; } EGenericType requiredType = object.eClass() .getFeatureType(TextualCommonsPackage.eINSTANCE.getUMLReferencingElement_ReferencedElement()); Collection<IEObjectDescription> foundElements = Sets.newHashSet(globalScopeProvider .queryScope(object.eResource(), true, (EClass) requiredType.getEClassifier(), Predicates.alwaysTrue()) .getAllElements()); List<EObject> matchingElements = foundElements.stream().filter(d -> qn.equals(d.getQualifiedName())) .map(IEObjectDescription::getEObjectOrProxy).distinct().collect(Collectors.toList()); if (matchingElements.size() == 1) { if (matchingElements.get(0) != object.getReferencedElement()) { object.setReferencedElement((Element) matchingElements.get(0)); } } else { object.setReferencedElement(null); } }
private List<?> getChoiceOfObjects(String parameterName) { if (parameterName != null) { EParameterDef def = ActivityDictionary.getInstance().getAttributeDef(parameterName); if (def != null) { EGenericType eGenericType = def.getEGenericType(); EClassifier classifier = eGenericType.getEClassifier(); if (classifier instanceof EEnumImpl) { EEnumImpl enumImpl = (EEnumImpl) classifier; return enumImpl.getELiterals(); } LogUtil.warn("Row Highlighting only supports Enum types. Not supported for " + parameterName + " (" +classifier+")."); } else { LogUtil.error("Invalid parameter name for Row Highligther: "+ parameterName); } } return Collections.EMPTY_LIST; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public EGenericType getFeatureType(EStructuralFeature feature) { int featureID = getFeatureID(feature); if (featureID != -1) { if (eAllStructuralFeatureTypes == null) { EGenericType[] result = new EGenericType[eAllStructuralFeaturesData.length]; for (int i = 0; i < eAllStructuralFeaturesData.length; ++i) { EGenericType eGenericType = eAllStructuralFeaturesData[i].getEGenericType(); if (eGenericType != null) { result[i] = EcoreUtil.getReifiedType(this, eGenericType); } } eAllStructuralFeatureTypes = result; } return eAllStructuralFeatureTypes[featureID]; } else { return feature.getEGenericType(); } }
public NotificationChain setEGenericType(EGenericType newEGenericType, NotificationChain msgs) { if (newEGenericType != eGenericType) { if (eGenericType != null) msgs = ((InternalEObject)eGenericType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EcorePackage.ETYPED_ELEMENT__EGENERIC_TYPE, null, msgs); if (newEGenericType != null) msgs = ((InternalEObject)newEGenericType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EcorePackage.ETYPED_ELEMENT__EGENERIC_TYPE, null, msgs); msgs = basicSetEGenericType(newEGenericType, msgs); } else if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EcorePackage.ETYPED_ELEMENT__EGENERIC_TYPE, newEGenericType, newEGenericType); if (msgs == null) { msgs = notification; } else { msgs.add(notification); } } return msgs; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setEUpperBound(EGenericType newEUpperBound) { if (newEUpperBound != eUpperBound) { NotificationChain msgs = null; if (eUpperBound != null) msgs = ((InternalEObject)eUpperBound).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EcorePackage.EGENERIC_TYPE__EUPPER_BOUND, null, msgs); if (newEUpperBound != null) msgs = ((InternalEObject)newEUpperBound).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EcorePackage.EGENERIC_TYPE__EUPPER_BOUND, null, msgs); msgs = basicSetEUpperBound(newEUpperBound, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.EGENERIC_TYPE__EUPPER_BOUND, newEUpperBound, newEUpperBound)); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setELowerBound(EGenericType newELowerBound) { if (newELowerBound != eLowerBound) { NotificationChain msgs = null; if (eLowerBound != null) msgs = ((InternalEObject)eLowerBound).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EcorePackage.EGENERIC_TYPE__ELOWER_BOUND, null, msgs); if (newELowerBound != null) msgs = ((InternalEObject)newELowerBound).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EcorePackage.EGENERIC_TYPE__ELOWER_BOUND, null, msgs); msgs = basicSetELowerBound(newELowerBound, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EcorePackage.EGENERIC_TYPE__ELOWER_BOUND, newELowerBound, newELowerBound)); }
protected EClassifier getErasure(ETypeParameter eTypeParameter) { if (eTypeParameter == null) { return null; } else { boolean needEClass = eContainer instanceof EClass || eContainer instanceof EReference; boolean needEDataType = !needEClass && eContainer instanceof EAttribute; for (EGenericType eBound : eTypeParameter.getEBounds()) { EClassifier eRawType = eBound.getERawType(); if (needEClass ? eRawType instanceof EClass : needEDataType ? eRawType instanceof EDataType : eRawType!= null) { return eRawType; } } return needEClass ? EcorePackage.Literals.EOBJECT : EcorePackage.Literals.EJAVA_OBJECT; } }
private static boolean isCompatibleArguments(EList<EGenericType> instanceETypeArguments, EList<EGenericType> eTypeArguments) { // Check any argument, if present, for compatibility. // int size = instanceETypeArguments.size(); if (size > 0) { for (int i = 0; i < size; ++i) { if (!isCompatibleArgument(instanceETypeArguments.get(i), eTypeArguments.get(i))) { return false; } } } return true; }
protected static boolean isEqualArguments(EList<EGenericType> instanceETypeArguments, EList<EGenericType> eTypeArguments) { // Check all the arguments, if any, for equality. // int size = instanceETypeArguments.size(); if (size != 0) { for (int i = 0; i < size; ++i) { if (!isEqualArgument(instanceETypeArguments.get(i), eTypeArguments.get(i))) { return false; } } } return true; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case EcorePackage.EGENERIC_TYPE__EUPPER_BOUND: setEUpperBound((EGenericType)newValue); return; case EcorePackage.EGENERIC_TYPE__ETYPE_ARGUMENTS: getETypeArguments().clear(); getETypeArguments().addAll((Collection<? extends EGenericType>)newValue); return; case EcorePackage.EGENERIC_TYPE__ELOWER_BOUND: setELowerBound((EGenericType)newValue); return; case EcorePackage.EGENERIC_TYPE__ETYPE_PARAMETER: setETypeParameter((ETypeParameter)newValue); return; case EcorePackage.EGENERIC_TYPE__ECLASSIFIER: setEClassifier((EClassifier)newValue); return; } eDynamicSet(featureID, newValue); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case EcorePackage.EGENERIC_TYPE__EUPPER_BOUND: setEUpperBound((EGenericType)null); return; case EcorePackage.EGENERIC_TYPE__ETYPE_ARGUMENTS: getETypeArguments().clear(); return; case EcorePackage.EGENERIC_TYPE__ELOWER_BOUND: setELowerBound((EGenericType)null); return; case EcorePackage.EGENERIC_TYPE__ETYPE_PARAMETER: setETypeParameter((ETypeParameter)null); return; case EcorePackage.EGENERIC_TYPE__ECLASSIFIER: setEClassifier((EClassifier)null); return; } eDynamicUnset(featureID); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case EcorePackage.ETYPE_PARAMETER__EANNOTATIONS: getEAnnotations().clear(); getEAnnotations().addAll((Collection<? extends EAnnotation>)newValue); return; case EcorePackage.ETYPE_PARAMETER__NAME: setName((String)newValue); return; case EcorePackage.ETYPE_PARAMETER__EBOUNDS: getEBounds().clear(); getEBounds().addAll((Collection<? extends EGenericType>)newValue); return; } eDynamicSet(featureID, newValue); }
private void extractEventParameters() { eventClass.getEReferences().forEach(f -> { final List<EGenericType> genericTypes = ((EClass) f.getEType()).getEGenericSuperTypes(); final List<EGenericType> typeArguments = genericTypes.get(0).getETypeArguments(); final EClass correspondingClass = (EClass) typeArguments.get(0).getEClassifier(); eventParameterClasses.add(correspondingClass); referenceToParameterClass.put(f, correspondingClass); }); }
public EClass getReferenceType(EReference reference, EClass context) { EGenericType genericType = reference.getEGenericType(); if (genericType == null) { return reference.getEReferenceType(); } EGenericType boundGenericType = getBoundGenericType(genericType, context); if (boundGenericType.getEClassifier() == null) { throw new IllegalStateException("Either typeParameter or eRawType must be set in EGenericType " + genericType); } return (EClass) boundGenericType.getEClassifier(); }
private EEnum getEEnum(String parameterName) { EParameterDef def = ActivityDictionary.getInstance().getAttributeDef(parameterName); if (def != null) { EGenericType eGenericType = def.getEGenericType(); EClassifier classifier = eGenericType.getEClassifier(); if (classifier instanceof EEnumImpl) { return (EEnum) classifier; } } return null; }
/** * Complete the initialization of the package and its meta-model. This * method is guarded to have no affect on any invocation but its first. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void initializePackageContents() { if (isInitialized) return; isInitialized = true; // Initialize package setName(eNAME); setNsPrefix(eNS_PREFIX); setNsURI(eNS_URI); // Create type parameters // Set bounds for type parameters // Add supertypes to classes // Initialize classes, features, and operations; add parameters initEClass(personEClass, Person.class, "Person", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getPerson_Name(), ecorePackage.getEString(), "name", "", 0, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPerson_Age(), ecorePackage.getEInt(), "age", "-1", 0, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); EOperation op = initEOperation(getPerson__HasName__DiagnosticChain_Map(), ecorePackage.getEBoolean(), "hasName", 0, 1, IS_UNIQUE, IS_ORDERED); addEParameter(op, ecorePackage.getEDiagnosticChain(), "chain", 0, 1, IS_UNIQUE, IS_ORDERED); EGenericType g1 = createEGenericType(ecorePackage.getEMap()); EGenericType g2 = createEGenericType(); g1.getETypeArguments().add(g2); g2 = createEGenericType(); g1.getETypeArguments().add(g2); addEParameter(op, g1, "context", 0, 1, IS_UNIQUE, IS_ORDERED); // Create resource createResource(eNS_URI); // Create annotations // http://www.eclipse.org/emf/2002/Ecore createEcoreAnnotations(); }
/** * Converts a generic type to its Java representation. * @param eGenericType the generic type to convert. * @return the Java representation of the generic type. */ public String toJavaInstanceTypeName(EGenericType eGenericType) { StringBuilder result = new StringBuilder(); convertJavaInstanceTypeName(result, eGenericType); return result.toString(); }
private static boolean hasReifiedType(Map<ETypeParameter, EGenericType> substitutions, EGenericType eGenericType) { ETypeParameter eTypeParameter = eGenericType.getETypeParameter(); if (eTypeParameter != null) { return substitutions.containsKey(eTypeParameter); } else { EList<EGenericType> eTypeArguments = eGenericType.getETypeArguments(); if (!eTypeArguments.isEmpty()) { for (EGenericType eTypeArgument : eTypeArguments) { if (hasReifiedType(substitutions, eTypeArgument)) { return true; } } return false; } else { EGenericType eLowerBound = eGenericType.getELowerBound(); if (eLowerBound != null) { return hasReifiedType(substitutions, eLowerBound); } else { EGenericType eUpperBound = eGenericType.getEUpperBound(); return eUpperBound != null && hasReifiedType(substitutions, eUpperBound); } } } }
public void setEType(EClassifier newEType) { NotificationChain msgs = setEType(newEType, null); EGenericType newEGenericType = null; if (newEType != null) { newEGenericType = EcoreFactory.eINSTANCE.createEGenericType(); newEGenericType.setEClassifier(eType); } msgs = setEGenericType(newEGenericType, msgs); if (msgs != null) { msgs.dispatch(); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public NotificationChain basicSetEGenericType(EGenericType newEGenericType, NotificationChain msgs) { EGenericType oldEGenericType = eGenericType; eGenericType = newEGenericType; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EcorePackage.ETYPED_ELEMENT__EGENERIC_TYPE, oldEGenericType, newEGenericType); if (msgs == null) msgs = notification; else msgs.add(notification); } if (newEGenericType == null) { if (eType != null) { msgs = setEType(null, msgs); } } else { EClassifier newEType = ((EGenericTypeImpl)newEGenericType).basicGetERawType(); if (newEType != eType) { msgs = setEType(newEType, msgs); } } return msgs; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public void setEGenericType(EGenericType newEGenericType) { NotificationChain msgs = setEGenericType(newEGenericType, null); if (msgs != null) { msgs.dispatch(); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case EcorePackage.ETYPED_ELEMENT__EANNOTATIONS: getEAnnotations().clear(); getEAnnotations().addAll((Collection<? extends EAnnotation>)newValue); return; case EcorePackage.ETYPED_ELEMENT__NAME: setName((String)newValue); return; case EcorePackage.ETYPED_ELEMENT__ORDERED: setOrdered((Boolean)newValue); return; case EcorePackage.ETYPED_ELEMENT__UNIQUE: setUnique((Boolean)newValue); return; case EcorePackage.ETYPED_ELEMENT__LOWER_BOUND: setLowerBound((Integer)newValue); return; case EcorePackage.ETYPED_ELEMENT__UPPER_BOUND: setUpperBound((Integer)newValue); return; case EcorePackage.ETYPED_ELEMENT__ETYPE: setEType((EClassifier)newValue); return; case EcorePackage.ETYPED_ELEMENT__EGENERIC_TYPE: setEGenericType((EGenericType)newValue); return; } eDynamicSet(featureID, newValue); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetEUpperBound(EGenericType newEUpperBound, NotificationChain msgs) { EGenericType oldEUpperBound = eUpperBound; eUpperBound = newEUpperBound; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EcorePackage.EGENERIC_TYPE__EUPPER_BOUND, oldEUpperBound, newEUpperBound); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<EGenericType> getETypeArguments() { if (eTypeArguments == null) { eTypeArguments = new EObjectContainmentEList<EGenericType>(EGenericType.class, this, EcorePackage.EGENERIC_TYPE__ETYPE_ARGUMENTS); } return eTypeArguments; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetELowerBound(EGenericType newELowerBound, NotificationChain msgs) { EGenericType oldELowerBound = eLowerBound; eLowerBound = newELowerBound; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EcorePackage.EGENERIC_TYPE__ELOWER_BOUND, oldELowerBound, newELowerBound); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; }
protected EAttribute initEAttribute (EAttribute a, EGenericType type, String name, String defaultValue, int lowerBound, int upperBound, Class<?> containerClass, boolean isTransient, boolean isVolatile, boolean isChangeable, boolean isUnsettable, boolean isID, boolean isUnique, boolean isDerived, boolean isOrdered) { initEStructuralFeature (a, type, name, defaultValue, lowerBound, upperBound, containerClass, isTransient, isVolatile, isChangeable, isUnsettable, isUnique, isDerived, isOrdered); a.setID(isID); return a; }
private void initEStructuralFeature (EStructuralFeature s, EGenericType type, String name, String defaultValue, int lowerBound, int upperBound, Class<?> containerClass, boolean isTransient, boolean isVolatile, boolean isChangeable, boolean isUnsettable, boolean isUnique, boolean isDerived, boolean isOrdered) { s.setName(name); ((EStructuralFeatureImpl)s).setContainerClass(containerClass); s.setTransient(isTransient); s.setVolatile(isVolatile); s.setChangeable(isChangeable); s.setUnsettable(isUnsettable); s.setUnique(isUnique); s.setDerived(isDerived); s.setOrdered(isOrdered); s.setLowerBound(lowerBound); s.setUpperBound(upperBound); s.setEGenericType(type); if (defaultValue != null) { s.setDefaultValueLiteral(defaultValue); } }
@Deprecated protected void addEParameter(EOperation owner, EGenericType type, String name, int lowerBound, int upperBound) { EParameter p = ecoreFactory.createEParameter(); p.setEGenericType(type); p.setName(name); owner.getEParameters().add(p); p.setLowerBound(lowerBound); p.setUpperBound(upperBound); }
protected void addEParameter(EOperation owner, EGenericType type, String name, int lowerBound, int upperBound, boolean isUnique, boolean isOrdered) { EParameter p = ecoreFactory.createEParameter(); p.setEGenericType(type); p.setName(name); owner.getEParameters().add(p); p.setLowerBound(lowerBound); p.setUpperBound(upperBound); p.setUnique(isUnique); p.setOrdered(isOrdered); }
@Override protected EGenericType createEGenericType() { EGenericTypeImpl eGenericType = (EGenericTypeImpl)super.createEGenericType(); eGenericTypes.add(eGenericType); return eGenericType; }