[rules-users] boolean == String?

Carlsen, Len len.carlsen at ubc.ca
Wed Feb 6 16:06:16 EST 2008


I forgot to say that I am using Drools 4.0.4

 

Len

 

________________________________

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Carlsen, Len
Sent: Wednesday, February 06, 2008 12:55 PM
To: Rules Users List
Subject: [rules-users] boolean == String?

 

Hi,

 

I have an expression where I am comparing a Boolean to a String which I
would expect to fail but the expression always returns true. Is this
expected behaviour?

 

I modified the Drools HelloWorldExample and changed the status from an
int to a boolean.

 

import org.drools.examples.HelloWorldExample.Message;

rule "Hello World"

    when

        m : Message( status == "hello", message : message )

    then

        System.out.println( message ); 

end

 

public static class Message {

        public static final boolean HELLO   = false;

        public static final boolean GOODBYE = true;

        private String message;

        private Boolean status;

 

        public Message() {}

        public String getMessage() { return this.message; }

        public void setMessage(final String message) { this.message =
message; }

        public boolean getStatus() { return this.status; }

        public void setStatus(final boolean status) { this.status =
status; }

}

 

 

final Message message = new Message();

message.setMessage( "Hello World" );

message.setStatus( Message.HELLO );

 

final StatefulSession session = ruleBase.newStatefulSession();

session.insert( message );

session.fireAllRules();

 

 

Thanks very much,

 

Len

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080206/4d4ef5ef/attachment.html 


More information about the rules-users mailing list