This may be an easy one, but I haven't found an easy way to determine in a rule that an object in working memory represented by an implemented interface is a specific class in IBM Rules Designer 8.8.1. For example, assuming HousingPeriod
is an interface, if I have a definition that states:
definitions
set 'the housing period' to a housing period...
And I want to follow that with a where
clause that further refines the collection of objects that implement HousingPeriod
as one of a list of implementing classes, say CollegeHousingPeriod
and InternshipHousingPeriod
, how could I do that? Something like:
where this housing period is a college housing period
or
where any of the following is true:
- this housing period is a college housing period
- this housing period is an internship housing period,
doesn't seem to work. Thanks in advance for any help you can provide!
As far as I know there is no built in way to query the type of an object. Instead I see two possible ways to get the desired result:
Create a virtual BOM entry with a custom B2X-mapping for each of your implementing classes. In the B2X-Mapping, you implement the necessary Java code to compare the object type and return a boolean. Verbalization would be something like
{1} is a college housing period
. This obviously only works if you know the objects before and there are not too many of them.Option two is to not create different objects but to use a seperate attribute to distinguish housing period types. The verbalization would then be something like
where the type of this housing period is college housing
. With this approach you’d have to change the interface of your rules project, which might not be possible for you.