[rules-users] Test for Empty String?

Wolfgang Laun wolfgang.laun at gmail.com
Thu Nov 5 02:27:04 EST 2009


Well, in the end it's all Java, so why should there be a better method? ;-)

I find that writing the constructors of fact objects so that they avoid
null values by setting fields to appropriate "Null" objects improves
things somewhat. In your case perhaps

CitatioDTO(){
   charge = Charge.NO_CHARGE;
   ...
}

and class Charge contains

   public static final NO_CHARGE = Charge( "",... );

-W

2009/11/5 Jason Davidson <jljdavidson at gmail.com>

> Hello,
>
> Is there an easy way to test if a String value is empty?  I've been doing
> this (Drools 4.0.7):
>     when CitationDTO
>         (
>             charge != null   &&
>             charge.drivingIncidentLegalSpeedRate != null   &&
>             charge.drivingIncidentLegalSpeedRate != ""
>         )
>     then ......
>
> It seems like there has to be a better method.
>
> Thanks,
> Jason
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091105/b31a54af/attachment.html 


More information about the rules-users mailing list