Test for Empty String?

View: New views
2 Messages — Rating Filter:   Alert me  

Test for Empty String?

by Jason Davidson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
https://lists.jboss.org/mailman/listinfo/rules-users

Re: Test for Empty String?

by Wolfgang Laun-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>
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@...
https://lists.jboss.org/mailman/listinfo/rules-users



_______________________________________________
rules-users mailing list
rules-users@...
https://lists.jboss.org/mailman/listinfo/rules-users