Search code examples
talend

Compare String using tMap


I am using Talend to prepare dataware. I want to compare the string with the contents of a column using the tMap component and create a variable to store in the DB. The problem is that the == operator does not give the right result (Example: row2.recipient == "text"?"text":"" I always get "") and if I use .equals I get errors when executing.


Solution

  • You will get error if row2.recipient is null, and "==" should not be used when comparing strings. Correct syntax would be :

    "text".equals(row2.recipient)?"text":""
    

    Then you will prevent NullPointerExceptions.