[rules-users] PlanningVariables are sometimes null

Geoffrey De Smet ge0ffrey.spam at gmail.com
Fri Aug 31 07:23:43 EDT 2012


Op 31-08-12 12:33, Michiel Vermandel schreef:
> Hi,
>
> I've got an planningEntity with two planningVariables.
> For both variables I build a list of objects.
> While solving, it seems that the planningEntity objects are sometimes
> called without setting the planning variables.
> When I read an attribute of such a variable in a rule I get a NPE, ofcourse.
> Is it possible to always have the planningsvariables to be set before
> executing a rule?
>
No, because the construction heuristics want to insert all entities in 
the WM, before initializing the plannin variables (sometimes only 1 of 
out of multiple planning variables per step).

Create a null safe getter:
ShiftAssignment:
public Contract getEmployeeContract() {
   return employee == null ? null : employee.getContract();
}



> Or am I missing the obvious?
>
> Thanks,
>
> Michiel
> -----------------
> http://www.codessentials.com - Your essential software, for free!
> Follow us at http://twitter.com/#!/Codessentials
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list