Four Stars

[resolved] tJavaRow and ternary operator?

Greetings, I need to check for a specific string in a column before I allow another column pass through its value, if not I want to make it 0.
For example, I have two columns (A, B) with two rows.
# A B
1 100 C
2 50 M
Column A is a Big Decimal and column B is a String. I run the flow through a tJavaRow and I use the condition:
output_row.ColumnA = input_row.ColumnB.equals("C") ? input_row.ColumnA : 0;
So after tJavaRow, the results look like
# A B
1 100 C
2 0 M
However, I am getting this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from Number&Comparable<?> to BigDecimal
Is there something wrong with my Java? Or is this not allowed in Talend?
Thank you!
1 ACCEPTED SOLUTION

Accepted Solutions
Four Stars

Re: [resolved] tJavaRow and ternary operator?

The java was wrong, I got it fixed:
output_row.ColumnA = input_row.ColumnB.equals("C") ? input_row.ColumnA : new BigDecimal(0);
1 REPLY
Four Stars

Re: [resolved] tJavaRow and ternary operator?

The java was wrong, I got it fixed:
output_row.ColumnA = input_row.ColumnB.equals("C") ? input_row.ColumnA : new BigDecimal(0);