Specifying conditions for move and submap mapping rules

In model-to-model transformations, when you specify a condition, a mapping rule is applied to an instance of the input element only when the Java™ code that is specified returns a Boolean value of true. If you do not specify a condition, the mapping rule is always applied when you run the transformation. You can specify semantic refinements by using the Object Constraint Language (OCL) API that Eclipse provides.

Before you begin

You must have a mapping model open. A mapping model has .mapping as a file name extension. The mapping model must contain at least one mapping declaration, which must contain at least one move or submap mapping rule.


  1. In the editor area, right-click the mapping rule; then click Show in Properties.
  2. In the Properties view, click the Condition tab.
  3. To create a condition, select the Apply a condition to this transformation check box.
  4. To specify the implementation details of the condition, complete one of the following steps:
    • To specify Java code that runs inline when you run the transformation, click Inline in the text area below the Code option. Specify the Java source code in the text area below the Inline button; then click Apply. The code that you specify must return a Boolean value.
      Tip: To see a list of valid variable names, in the text area below the Inline button, press Ctrl+Space.
    • To specify code that is in a Java class, click External. In the Class field, specify the Java class that contains the code. Click Browse to select a valid class from the workspace.
      Note: The Java class that you specify must extend the org.eclipse.emf.query.conditions.Condition class. The isSatisfied() method of the class that you specify is invoked with an instance of the input element, and the method returns a Boolean value.
      Tip: To create a Java class that implements a condition, click New; then complete the fields in the New Java Class window.
  5. Click File > Save.