Mapping a method call using extender mapping

You can use extender mapping to map a method call.

About this task

You can map a method call to any given expression, using extender mapping.

Procedure

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 must be an execution class type followed by the other parameters with execution types, as for a static method.

  4. Save the BOM.

Results

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;
  }
}