@Override public EList<ETypeParameter> caseEClassifier(EClassifier eClassifier) { return eClassifier.getETypeParameters(); }
protected boolean isTemplate(EClassifier eClassifier) { return eClassifier.getETypeParameters().size() > 0; }
protected ETypeParameter addETypeParameter(EClassifier owner, String name) { ETypeParameter eTypeParameter = ecoreFactory.createETypeParameter(); eTypeParameter.setName(name); owner.getETypeParameters().add(eTypeParameter); return eTypeParameter; }
@Override public Collection<?> getChoiceOfValues(Object object) { Collection<Object> result = new ArrayList<Object>(); result.add(null); for (EObject eObject = (EObject)object; eObject != null; eObject = eObject.eContainer()) { if (eObject instanceof EClassifier) { result.addAll(((EClassifier)eObject).getETypeParameters()); } else if (eObject instanceof EOperation) { result.addAll(((EOperation)eObject).getETypeParameters()); } result.remove(eObject); } return result; }
protected ETypeParameter addETypeParameter(EClassifier owner, String name) { ETypeParameter eTypeParameter = ecoreFactory.createETypeParameter(); eTypeParameter.setName(name); owner.getETypeParameters().add(eTypeParameter); return eTypeParameter; }
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); } } }
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); } } }
void handleTypeArguments(XSDTypeDefinition xsdTypeDefinition, EClassifier eClassifier) { XSDAnnotation xsdAnnotation = xsdTypeDefinition.getAnnotation(); if (xsdAnnotation != null) { List<Element> applicationInformationList = xsdAnnotation.getApplicationInformation(EcorePackage.eNS_URI); for (Element applicationInformation : applicationInformationList) { if ("typeParameters".equals(applicationInformation.getAttributeNS(EcorePackage.eNS_URI, "key"))) { for (Element typeParameter : getElements(applicationInformation, "typeParameter")) { ETypeParameter eTypeParameter = EcoreFactory.eINSTANCE.createETypeParameter(); String typeParameterName = typeParameter.getAttributeNS(null, "name"); eTypeParameter.setName(typeParameterName); eClassifier.getETypeParameters().add(eTypeParameter); eTypeParameter.getEBounds().addAll(getGenericTypes(xsdTypeDefinition, typeParameter, eClassifier, typeParameter.getAttributeNS(null, "bounds"))); } } } } }
void handleTypeArguments(XSDTypeDefinition xsdTypeDefinition, EClassifier eClassifier) { XSDAnnotation xsdAnnotation = xsdTypeDefinition.getAnnotation(); if (xsdAnnotation != null) { List<Element> applicationInformationList = xsdAnnotation.getApplicationInformation(EcorePackage.eNS_URI); for (Element applicationInformation : applicationInformationList) { if ("typeParameters".equals(applicationInformation.getAttributeNS(EcorePackage.eNS_URI, "key"))) { for (Element typeParameter : getElements(applicationInformation, "typeParameter")) { ETypeParameter eTypeParameter = EcoreFactory.eINSTANCE.createETypeParameter(); String typeParameterName = typeParameter.getAttributeNS(null, "name"); eTypeParameter.setName(typeParameterName); eClassifier.getETypeParameters().add(eTypeParameter); eTypeParameter.getEBounds().addAll(getGenericTypes(xsdTypeDefinition, typeParameter, eClassifier, typeParameter.getAttributeNS(null, "bounds"))); } } } } }
protected void handleEClassifier(EClassifier classifier, Set<EPackage> visitedPackages, Set<Object> visited) { if (classifier != null && visited.add(classifier)) { handleEPackage(classifier.getEPackage(), visitedPackages); handleETypeParameters(classifier.getETypeParameters(), visitedPackages, visited); if (classifier instanceof EClass) { EClass eClass = (EClass)classifier; handleEStructuralFeatures(eClass.getEStructuralFeatures(), visitedPackages, visited); handleEOperations(eClass.getEOperations(), visitedPackages, visited); handleEGenericTypes(eClass.getEGenericSuperTypes(), visitedPackages, visited); } } }
protected void handleEClassifier(EClassifier classifier, Set<EClassifier> visited) { if (classifier != null && visited.add(classifier)) { handleEPackage(classifier.getEPackage(), visitedPackages); handleETypeParameters(classifier.getETypeParameters(), visited); if (classifier instanceof EClass) { EClass eClass = (EClass)classifier; handleEStructuralFeatures(eClass.getEStructuralFeatures(), visited); handleEOperations(eClass.getEOperations(), visited); handleEGenericTypes(eClass.getEGenericSuperTypes(), visited); } } }
.getETypeParameters(); int eTypeParametersSize = eTypeParameters.size();
public static EClassifier getTypeArgument(EClass eClass, EGenericType eGenericType) { ETypeParameter eTypeParameter = eGenericType.getETypeParameter(); if( eTypeParameter != null ) { for (EGenericType eGenericSuperType : eClass.getEAllGenericSuperTypes()) { EList<ETypeParameter> eTypeParameters = eGenericSuperType .getEClassifier().getETypeParameters(); int index = eTypeParameters.indexOf(eTypeParameter); if (index != -1 && eGenericSuperType.getETypeArguments().size() > index) { return getTypeArgument(eClass, eGenericSuperType .getETypeArguments().get(index)); } } return null; } else { return eGenericType.getEClassifier(); } }
public static EClassifier getTypeArgument(EClass eClass, EGenericType eGenericType) { ETypeParameter eTypeParameter = eGenericType.getETypeParameter(); if( eTypeParameter != null ) { for (EGenericType eGenericSuperType : eClass.getEAllGenericSuperTypes()) { EList<ETypeParameter> eTypeParameters = eGenericSuperType .getEClassifier().getETypeParameters(); int index = eTypeParameters.indexOf(eTypeParameter); if (index != -1 && eGenericSuperType.getETypeArguments().size() > index) { return getTypeArgument(eClass, eGenericSuperType .getETypeArguments().get(index)); } } return null; } else { return eGenericType.getEClassifier(); } }
if (eGenericType.getEClassifier() != null && !eGenericType.getEClassifier().getETypeParameters().isEmpty())
public GenTypeParameter findGenTypeParameter(ETypeParameter eTypeParameter) { for (EObject eObject = eTypeParameter.eContainer(); eObject != null; eObject = eObject.eContainer()) { if (eObject instanceof EOperation) { EOperation eOperation = (EOperation)eObject; int index = eOperation.getETypeParameters().indexOf(eTypeParameter); if (index != -1) { GenOperation genOperation = findGenOperation(eOperation); return genOperation.getGenTypeParameters().get(index); } } else if (eObject instanceof EClassifier) { EClassifier eClassifier = (EClassifier)eObject; int index = eClassifier.getETypeParameters().indexOf(eTypeParameter); if (index != -1) { GenClassifier genClassifier = findGenClassifier(eClassifier); return genClassifier.getGenTypeParameters().get(index); } } } return null; }
eGenericType = EcoreFactory.eINSTANCE.createEGenericType(); eGenericType.setEClassifier(eClassifier); for (int i = 0, size = eClassifier.getETypeParameters().size(); i < size; ++i)
public boolean hasEDefault() { return getEcoreFeature() instanceof EAttribute && (getEffectiveComplianceLevel().getValue() < GenJDKLevel.JDK50 || (getEcoreFeature().getEType().getETypeParameters().isEmpty() && getEcoreFeature().getEGenericType().getETypeParameter() == null && getEcoreFeature().getEType().getInstanceTypeName() == getEcoreFeature().getEType().getInstanceClassName())); }
public boolean hasEDefault() { return getEcoreFeature() instanceof EAttribute && (getEffectiveComplianceLevel().getValue() < GenJDKLevel.JDK50 || (getEcoreFeature().getEType() != null && getEcoreFeature().getEType().getETypeParameters().isEmpty() && getEcoreFeature().getEGenericType().getETypeParameter() == null && getEcoreFeature().getEType().getInstanceTypeName() == getEcoreFeature().getEType().getInstanceClassName())); }