| ILOG JRules User Guide > Creating Rule Projects > Tasks > Defining How Business Elements Map to the XOM > Mapping a Method Call to an Expression |
Mapping a Method Call to an Expression |
PREVIOUS NEXT |
You can map a method call to any given expression.
To map a method call to an expression using IRL mapping:
this to represent the current object.
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:
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;
}
}
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |