public static void markFeatureAsStatic(EStructuralFeature eFeature) { IntermediateStaticFieldAdapter adapter = (IntermediateStaticFieldAdapter) EcoreUtil.getAdapter(eFeature.eAdapters(), IntermediateStaticFieldAdapter.class); if (adapter == null) { adapter = new IntermediateStaticFieldAdapter(); eFeature.eAdapters().add(adapter); } }
@Override public void eSet(EStructuralFeature feature, Object newValue) { IntermediateStaticFieldAdapter adapter = (IntermediateStaticFieldAdapter) EcoreUtil.getAdapter(feature.eAdapters(), IntermediateStaticFieldAdapter.class); if (adapter != null) { adapter.eSet(feature, newValue); } super.eSet(feature, newValue); }
@Override public Object eGet(EStructuralFeature feature, boolean resolve, boolean coreType) { IntermediateStaticFieldAdapter adapter = (IntermediateStaticFieldAdapter) EcoreUtil.getAdapter(feature.eAdapters(), IntermediateStaticFieldAdapter.class); if (adapter != null) { return adapter.eGet(feature); } return super.eGet(feature, resolve, coreType); }
public void doInstancePropertyInit(Object instance, QvtOperationalEvaluationVisitor evalVisitor) { if (false == instance instanceof EObject) { return; } EObject eInstance = (EObject) instance; EClass intermediateClass = eInstance.eClass(); Map<EStructuralFeature, OCLExpression<EClassifier>> clsFeatures = myClassifierInitializations.get(intermediateClass); if (clsFeatures == null) { return; } for (EStructuralFeature eFeature : intermediateClass.getEAllStructuralFeatures()) { IntermediateStaticFieldAdapter adapter = (IntermediateStaticFieldAdapter) EcoreUtil.getAdapter(eFeature.eAdapters(), IntermediateStaticFieldAdapter.class); if (adapter != null && adapter.isInitialized()) { continue; } OCLExpression<EClassifier> expression = clsFeatures.get(eFeature); Object evalResult = expression != null ? evalVisitor.visitExpression(expression) : null; if (evalResult == null) { // no init expression specified for a single-valued feature, or init expression evaluated to // null EClassifier featureType = evalVisitor.getEnvironment().getUMLReflection().getOCLType(eFeature); evalResult = EvaluationUtil.createInitialValue( featureType, evalVisitor.getEnvironment().getOCLStandardLibrary(), evalVisitor.getEvaluationEnvironment()); } // temporary switch off read-only property boolean isChangeable = eFeature.isChangeable(); eFeature.setChangeable(true); boolean isUndefined = QvtOperationalUtil.isUndefined(evalResult, evalVisitor.getEvaluationEnvironment()); evalVisitor .getOperationalEvaluationEnv() .callSetter(eInstance, eFeature, evalResult, isUndefined, true); eFeature.setChangeable(isChangeable); } }
public static boolean isFeatureStatic(EStructuralFeature eFeature) { return EcoreUtil.getAdapter(eFeature.eAdapters(), IntermediateStaticFieldAdapter.class) != null; }