-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
bugSomething isn't workingSomething isn't workingmodelserverEMF.cloud Model ServerEMF.cloud Model Server
Description
In class 'org.eclipse.emfcloud.modelserver.example.util.PrintUtil.java', the default case in the switch statement needs to account for the case of multi-valued attributes. The current code assumes all attributes are single-valued and fails with a ClassCastException when it encounters a multi-valued attribute. Here's the updated method that I used to fix the problem:
`@Override
public StringBuilder defaultCase(final EObject object) {
beginObject(object.eClass().getName() + " {");
for (EAttribute attr : object.eClass().getEAllAttributes()) {
Object value = object.eGet(attr);
if (value instanceof List) {
List<?> list = (List<?>) value;
if (!list.isEmpty()) {
for (Object oneValue : list) {
print(String.format("%s: %s", attr.getName(),
EcoreUtil.convertToString(attr.getEAttributeType(), oneValue)));
}
}
} else {
print(String.format("%s: %s", attr.getName(),
EcoreUtil.convertToString(attr.getEAttributeType(), object.eGet(attr))));
}
}
recurse(object);
endObject("}");
return result;
}`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingmodelserverEMF.cloud Model ServerEMF.cloud Model Server