Drools DRL String contains equals and equalsIgnoreCase - Java @ Desk

Thursday, April 17, 2014

Drools DRL String contains equals and equalsIgnoreCase


Drools DRL String contains equals and equalsIgnoreCase

In a normal java application, string operations like equals and contains operations can be performed on String objects.

Similarly, DRL file also supports String compare and equal operations.

Also, equal operation can be case sensitve and case insensitive using the equals and equalsIgnoreCase method.

Below is the DRL file which has three rules one for equals, equalsIgnoreCase and contains operations

package com.sample

rule "Rule To Check String Contains"
when
 Pojo(name.contains("Loans"))
then
 System.out.println(drools.getRule().getName());
end

rule "Rule To Check String Equals"
when
 Pojo(name.equals("Personal Loans, Insuarnce"))
then
 System.out.println(drools.getRule().getName());
end

rule "Rule To Check String EqualsIgnoreCase"
when
 Pojo(name.equalsIgnoreCase("Personal loans, insuarnce"))
then
 System.out.println(drools.getRule().getName());
end






No comments:

Post a Comment