title: Talend-Convert IF-THEN ELSE into Ternary operator
body: <p>We are trying to turn IF-THEN-ELSE statement of tableau Reporting/BI tool  <strong>INTO</strong> TERNARY OPERATOR Java Based Talend tool Or JAVA based IF-THEN-ELSE</p>
  
  <p><strong>Input Data</strong> </p>
  
  <pre><code>if isnull([Ship Date (Calculated)]) then
  (if (attr(trim([Corp Acct Name])) = 'ABC' 
  or attr(trim([Corp Acct Name])) ='BCD' 
  or attr(trim([Corp Acct Name])) ='CDE') 
  then 
  (if DATEPART('weekday',ATTR([ ShipDate])) =1 then (attr([ ShipDate])-3)
  elseif DATEPART('weekday',ATTR([ ShipDate])) =2 then (attr([ ShipDate])-3)
  else  (attr([ShipDate])-2) END
  ) else (if DATEPART('weekday',ATTR([ ShipDate])) =1 then (attr([ ShipDate])-2)
  else  (attr([ ShipDate])-1) END
  ) end)
  ELSE
  (if (attr(trim([Corp Acct Name])) = 'ABC' 
  or attr(trim([Corp Acct Name])) ='BCD' 
  or attr(trim([Corp Acct Name])) ='CDE') 
  then 
  (if DATEPART('weekday',[Ship Date (Calculated)])=1 then ([Ship Date (Calculated)]-3)
  elseif DATEPART('weekday',[Ship Date (Calculated)])=2 then ([Ship Date (Calculated)]-3)
  else ([Ship Date (Calculated)]-2) end)
   else (if DATEPART('weekday',[Ship Date (Calculated)])=1 then ([Ship Date (Calculated)]-2)
  else ([Ship Date (Calculated)]-1) end) end)
  END
  </code></pre>
  
  <p><strong>Used Field and its data type here</strong></p>
  
  <pre><code>[Ship Date (Calculated)]- date
  [Corp Acct Name] -String
  [ ShipDate] - Date
  </code></pre>
  
  <p><strong>We tried:</strong></p>
  
  <pre><code>row1.ShipDateCalculated==null?("ABC".equalsIgnoreCase(row1.CorpAcctName) || "BCD".equalsIgnoreCase(row1.CorpAcctName
  ||"CDE".equalsIgnoreCase(row1.CorpAcctName))?(TalendDate.getPartOfDate("DAY_OF_WEEK",row1.ShipDate) ==1?TalendDate.addDate(TalendDate.formatDate("MM/dd/yyyy", row1.ShipDate ),"MM/dd/yyyy",-3,"dd"):
  (TalendDate.getPartOfDate("DAY_OF_WEEK",row1.ShipDate) ==2?TalendDate.addDate(TalendDate.formatDate("MM/dd/yyyy", row1.ShipDate ),"MM/dd/yyyy",-3,"dd"):TalendDate.addDate(TalendDate.formatDate("MM/dd/yyyy", row1.ShipDate ),"MM/dd/yyyy",-2,"dd")
  :(TalendDate.getPartOfDate("DAY_OF_WEEK",row1.ShipDate) ==1?TalendDate.addDate(TalendDate.formatDate("MM/dd/yyyy", row1.ShipDate ),"MM/dd/yyyy",-2,"dd"):TalendDate.addDate(TalendDate.formatDate("MM/dd/yyyy", row1.ShipDate ),"MM/dd/yyyy",-1,"dd"):""))
  </code></pre>
  
  <p><strong>Output Data:</strong></p>
  
  <p>Looking for ternary Operator based on JAVA.</p>
  
  <pre><code>condition1?(condition2?value if true:value if false): (condition3?value if true:value if false)
  </code></pre>
  
  <p>More Error : After adding else part on  current  tmap syntax.Getting error</p>
  
  <p><a href="https://i.stack.imgur.com/txjJo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/txjJo.png" alt="enter image description here"></a></p>