diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/expressions/UMLOCLFactory.java')
-rw-r--r-- | plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/expressions/UMLOCLFactory.java | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/expressions/UMLOCLFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/expressions/UMLOCLFactory.java index f972afaef35..a6448dac25d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/expressions/UMLOCLFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/src/org/eclipse/papyrus/uml/diagram/clazz/expressions/UMLOCLFactory.java @@ -48,9 +48,9 @@ public class UMLOCLFactory { */ protected UMLOCLFactory() { this.expressions = new UMLAbstractExpression[3]; - this.expressionBodies = new String[]{ "\' \'", //$NON-NLS-1$ - "not self.oclIsTypeOf(EnumerationLiteral)", //$NON-NLS-1$ - "self.association.oclIsUndefined()", //$NON-NLS-1$ + this.expressionBodies = new String[] { "\' \'", //$NON-NLS-1$ + "not self.oclIsTypeOf(EnumerationLiteral)", //$NON-NLS-1$ + "self.association.oclIsUndefined()", //$NON-NLS-1$ }; } @@ -59,7 +59,7 @@ public class UMLOCLFactory { */ private static UMLOCLFactory getInstance() { UMLOCLFactory instance = UMLDiagramEditorPlugin.getInstance().getUMLOCLFactory(); - if(instance == null) { + if (instance == null) { UMLDiagramEditorPlugin.getInstance().setUMLOCLFactory(instance = new UMLOCLFactory()); } return instance; @@ -75,13 +75,15 @@ public class UMLOCLFactory { /** * @generated */ - public static UMLAbstractExpression getExpression(int index, EClassifier context, Map<String, EClassifier> environment) { + public static UMLAbstractExpression getExpression(int index, EClassifier context, + Map<String, EClassifier> environment) { UMLOCLFactory cached = getInstance(); - if(index < 0 || index >= cached.expressions.length) { + if (index < 0 || index >= cached.expressions.length) { throw new IllegalArgumentException(); } - if(cached.expressions[index] == null) { - cached.expressions[index] = getExpression(cached.expressionBodies[index], context, environment == null ? Collections.<String, EClassifier> emptyMap() : environment); + if (cached.expressions[index] == null) { + cached.expressions[index] = getExpression(cached.expressionBodies[index], context, + environment == null ? Collections.<String, EClassifier>emptyMap() : environment); } return cached.expressions[index]; } @@ -91,7 +93,8 @@ public class UMLOCLFactory { * * @generated */ - public static UMLAbstractExpression getExpression(String body, EClassifier context, Map<String, EClassifier> environment) { + public static UMLAbstractExpression getExpression(String body, EClassifier context, + Map<String, EClassifier> environment) { return new Expression(body, context, environment); } @@ -101,7 +104,7 @@ public class UMLOCLFactory { * @generated */ public static UMLAbstractExpression getExpression(String body, EClassifier context) { - return getExpression(body, context, Collections.<String, EClassifier> emptyMap()); + return getExpression(body, context, Collections.<String, EClassifier>emptyMap()); } /** @@ -142,14 +145,14 @@ public class UMLOCLFactory { @Override @SuppressWarnings("rawtypes") protected Object doEvaluate(Object context, Map env) { - if(oclExpression == null) { + if (oclExpression == null) { return null; } // on the first call, both evalEnvironment and extentMap are clear, for later we have finally, below. EvaluationEnvironment<?, ?, ?, ?, ?> evalEnv = oclInstance.getEvaluationEnvironment(); // initialize environment - for(Object nextKey : env.keySet()) { - evalEnv.replace((String)nextKey, env.get(nextKey)); + for (Object nextKey : env.keySet()) { + evalEnv.replace((String) nextKey, env.get(nextKey)); } try { Object result = oclInstance.evaluate(context, oclExpression); @@ -163,10 +166,12 @@ public class UMLOCLFactory { /** * @generated */ - private static void initCustomEnv(Environment<?, EClassifier, ?, ?, ?, EParameter, ?, ?, ?, ?, ?, ?> ecoreEnv, Map<String, EClassifier> environment) { + private static void initCustomEnv(Environment<?, EClassifier, ?, ?, ?, EParameter, ?, ?, ?, ?, ?, ?> ecoreEnv, + Map<String, EClassifier> environment) { // Use EObject as implicit root class for any object, to allow eContainer() and other EObject operations from OCL expressions - ParsingOptions.setOption(ecoreEnv, ParsingOptions.implicitRootClass(ecoreEnv), EcorePackage.eINSTANCE.getEObject()); - for(String varName : environment.keySet()) { + ParsingOptions.setOption(ecoreEnv, ParsingOptions.implicitRootClass(ecoreEnv), + EcorePackage.eINSTANCE.getEObject()); + for (String varName : environment.keySet()) { EClassifier varType = environment.get(varName); ecoreEnv.addElement(varName, createVar(ecoreEnv, varName, varType), false); } @@ -175,7 +180,8 @@ public class UMLOCLFactory { /** * @generated */ - private static Variable createVar(Environment<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ecoreEnv, String name, EClassifier type) { + private static Variable createVar(Environment<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ecoreEnv, + String name, EClassifier type) { Variable var = EcoreFactory.eINSTANCE.createVariable(); var.setName(name); var.setType(ecoreEnv.getUMLReflection().getOCLType(type)); |