Why Equals its not "equals"?

17 views
Skip to first unread message

Davi Sáránszky Mesquita

unread,
Oct 29, 2021, 11:08:00 AM10/29/21
to drools...@googlegroups.com
Hi everyone, 

I'm having some issues comparing String values on Drools.

While using "then" works fine, but inside the "code" after using "then".  The code does not compare Strings using "==".



In Drools 7.59.0.Final

Using a bean class 

public class Exemplo {

private String segurado;

In Drools DRL

Dialect MVEL ( Both sentences are TRUE )

x.segurado == "teste")
x.getSegurado().equals( "teste"))

Using Dialect JAVA

1) False
x.getSegurado() == "teste")

2) True

x.getSegurado().equals( "teste"))


Davi
+55 (11) 9-6395-3728

Michael Anstis

unread,
Oct 29, 2021, 11:39:11 AM10/29/21
to Drools Usage

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/CAPgT8zHf%2B%3Df8FU1QVh7XZYb%2BqMQ9NZjTjiAv7xk2pQFM8LMhaw%40mail.gmail.com.

Davi Sáránszky Mesquita

unread,
Oct 29, 2021, 11:58:15 AM10/29/21
to drools...@googlegroups.com
wellwelll .... Thanks btw. Same old problem. Just forgotten

I did just inverted for better results

"teste".equals(x.getSegurado())


Davi




Michael Anstis

unread,
Oct 29, 2021, 12:05:32 PM10/29/21
to Drools Usage
No problem, glad you've got it working :-)

I favor Objects.equals(x, y) that handles null values reliably.

Reply all
Reply to author
Forward
0 new messages