[rules-users] compare string and int in LHS

brenner daniel.brenner at isg-stuttgart.de
Fri Feb 8 10:42:09 EST 2008


Thanks for your answer.

Yes, with eval it works. I had oversight it.

The question with the model I have aked myself. But I can't change it. There
are to much factors involved. Storable by Hibernate. Based on configuration
files with key-value, whereas the value could have various data types
(c-types) and all without a rule. Very bad, I know. 





Anstis, Michael (M.) wrote:
> 
> You could use an inline eval too.
> 
> The problem possibly lies more with your model; why not have one subclass
> expose the String property and another the Integer property and code the
> rules using the subclasses? Much safer throughout the entire application
> than having to worry whether some field is meant to be a string or number
> (It's very easy to question problems though - there could be very good
> reason why you need the model "as is").
> 
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of brenner
> Sent: 08 February 2008 12:33
> To: rules-users at lists.jboss.org
> Subject: Re: [rules-users] compare string and int in LHS
> 
> 
> Hi,
> 
> I have found a solution, but I don't know that it is the best:
> My solution:
> 
> I have extend my Class with a method which returns the string as a
> integer.
> And my rule is like this:
> 
> i : Integer( intValue <= 1) from $test.getValue(Test.VALUE_TYP_INTEGER);
> 
> Is that the only/best solution. 
> Can't I convert Strings to Integer on the LHS of a rule?
> 
> greeting
> Daniel
> 
> 
> 
> 
> brenner wrote:
>> 
>> Hi,
>> 
>> I have a class, wich contains a string value. This value is in some use
>> cases an integer. 
>> For this use case I want to convert (parse) the string typ to an integer
>> because I want that the following rule matches: 
>> 
>> rule
>>   when
>>     t : Test(value <= 1)
>>   then
>>     System.out.println(t)
>> end
>> 
>> 
>> class Test {
>>    
>>    String value;
>> 
>>    getValue();
>>    setValue();
>> 
>> }
>> 
>> Have anyone a solution or some help for me?
>> Is that possible what I want to do?
>> 
>> Thanks
>> Daniel
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15354435.html
> Sent from the drools - user mailing list archive at Nabble.com.
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
>  
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15357593.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list