ILOG JRules User Guide > Creating Rule Projects > Tasks > Defining How Business Elements Map to the XOM > Mapping a Method Call to an Expression

You can map a method call to any given expression.

To map a method call to an expression using IRL mapping:

  1. In the Outline view, click the method that you want to map to an expression.
  2. In the BOM Editor, in the BOM to XOM Mapping section, type the expression as an IRL statement in the Body field. Use this to represent the current object.
  3. Save the BOM.
  4. The method call is now mapped to an expression.

In this example, there is a class Customer in the XOM that contains a method that returns the age of the customer:

// Execution class
public class Customer {
   public int getAge() ...
}

In the BOM, there is a predicate that checks if the customer is older than a given age. The age is passed to the method as a parameter:

public class Customer {
   public boolean isOlderThan(int age);
}

The body of the method BOM to XOM mapping is expressed as:

return this.getAge() > age;

Extender mapping can be used to map a method call to an expression.

To map a method call to an expression using extender mapping:

  1. In the Outline view, click the class containing the method that you want to map to a expression.
  2. In the BOM Editor, in the BOM to XOM Mapping section, enter the name of your extender class in the Extender name field.
  3. Define the method as a Java static method with the same name as the method in the BOM. The return type of the extender method must map to the execution type corresponding to the BOM method return type. If the method is static, the parameters of the extender method have execution types that correspond to the types of the BOM method parameters. In the case of an instance method, the first parameter of the extender method has to be an execution class type followed by the other parameters with execution types, as for a static method.
  4. Save the BOM.
  5. The method call is now mapped to an expression.

In this example, the method that is used when the method isOlderThan is called is provided as a Java static method with the same name in the extender class.

public class ExtCustomer {  
  public static boolean isOlderThan(Customer customer, int age) {
    return customer.getAge() > age;
  }
}

Related Concepts

Business Object Model (BOM)
Execution Object Model (XOM)
BOM and XOM

Related Tasks

Defining How Business Elements Map to the XOM
Managing XOM Changes in the BOM

Related Reference

BOM Editor
ILOG Rule Language

Related Samples and Tutorials

Tutorial: Defining a Vocabulary