To make my previous email more understandable, I add a simple example code from the EMF-IncQuery codebase (available in the code of EMF-IncQuery in line 225
https://github.com/ujhelyiz/EMF-IncQuery/blob/master/plugins/org.eclipse.viatra2.patternlanguage.emf/src/org/eclipse/viatra2/patternlanguage/types/EMFPatternTypeProvider.java). The goal of the code segment is to provide the Java types for the EMF type of a variable. For your question, only the following snippet is needed, where the Type object is downcasted to the corresponding subtypes, then the className and refName attributes are used to get the EMF types.
protected JvmTypeReference resolve(Type type, Variable variable) {
if (type instanceof ClassType) {
return resolve((ClassType)type, variable);
}
if (type instanceof ReferenceType) {
return resolve((ReferenceType) type, variable);
}
return null;
}
protected JvmTypeReference resolve(ClassType type, Variable variable) {
final EClassifier classifier = type.getClassname();
if (classifier != null) {
return resolve(classifier, variable);
}
return null;
}
protected JvmTypeReference resolve(ReferenceType type,
Variable variable) {
final EStructuralFeature feature = type.getRefname();
if (feature instanceof EAttribute) {
return resolve((EAttribute) feature, variable);
}
if (feature instanceof EReference) {
return resolve((EReference)feature, variable);
}
return null;
}
I hope, this way it is more easy to understand,