public static Object setFromSlot(final EFactory eFactory, final EClass eClass, final EObject eObject, final AttributeSlot slot) throws IOException { final EStructuralFeature feature = eClass.getEStructuralFeature(slot.name); if (feature == null) { return null; } if (!feature.isChangeable() || feature.isDerived() && !(eObject instanceof DynamicEStoreEObjectImpl)) { return null; } if (!slot.isSetValue()) { return null; } // isSet=true and many=false means that we should have exactly one value final EClassifier eType = feature.getEType(); if (eType.eContainer() == EcorePackage.eINSTANCE) { return fromEcoreType(eClass, eObject, slot, feature, eType); } else if (eType instanceof EEnum) { return fromEnum(eFactory, eClass, eObject, slot, feature, (EEnum)eType); } else { return fromInstanceClass(eClass, eObject, slot, feature, eType); } }
public static Object setAttribute(final EFactory eFactory, final EClass eClass, final EObject eObject, final String featureName, final Object value) { final EStructuralFeature feature = eClass.getEStructuralFeature(featureName); if (feature == null) { return null; } if (!feature.isChangeable() || feature.isDerived() && !(eObject instanceof DynamicEStoreEObjectImpl)) { return null; } if (feature.isMany()) { return setListAttribute(eFactory, eObject, value, feature); } else { return setScalarAttribute(eFactory, eObject, value, feature); } }