Skip to content
𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ

Share the knowledge

Apache Camel – Null safe operator for ‘simple’ statement

Posted on April 15, 2017September 20, 2021 By sastrija

In Apache CamelΒ we use “simple” statement to extract values in a pojo.

For example if we have a pojo “Employee” having “employeeId” as one of the attribute,Β and employee object is available in camel exchange body, we can retrieve the employee id with following statement.

simple("${body.employeeId}");

If by chance body is null above statement will throw null pointer exception. Apache Camel provides a solution to avoid this situation. Β Use ?. instead of . to access attributes.

simple("${body?.employeeId}");

 

Related

Uncategorized

Post navigation

Previous post
Next post

Comments (2)

  1. Pierre Thibault says:
    May 8, 2017 at 10:48 pm

    Is the value of “${body?.employeeId}” is null if there is no employeeId property?

    1. Sastrija says:
      May 9, 2017 at 12:50 am

      Yes. Value will be “null” if object in body doesn’t have “employeeId” attribute.

Comments are closed.

©2026 𝓒π“ͺ𝓼𝓽𝓻𝓲𝓳π“ͺ | WordPress Theme by SuperbThemes