0
votes

I have one object of class "Applicant"

Applicant applicant = new Applicant("David", 37); // (name, experienceInYears)

Based on age of applicant, I am setting its role:

SuggestedRole suggestedRole = new SuggestedRole();
applicantService.suggestARoleForApplicant(applicant, suggestedRole);

My drool file is:

rule "Suggest Manager Role"
    when
        Applicant(experienceInYears > 10)
    then
        suggestedRole.setRole("Manager");
end

From: https://www.baeldung.com/drools

What I want to achieve is to perform same operation for List[Applicant]. One way is to iterate over list in Java and do same, but I am looking for drool solution. Is there anyway I can just configure drool to take List[Applicant] as input and return List[SuggestedRole]

1
I have millions of Applicant.user811602

1 Answers

1
votes

You shouldn't have to change anything. Drools does pattern matching. If you insert all of your Applicant objects into the Drools session then the same Drools rule evaluates applicants one by one and sets the suggested role where applicable.