Learn by product

Select the product you would like help with:

Martini Logo
Select the product you would like help with:
Community Q&A

Ask the Community

In my Gloop service, I want to add a custom mapping logic where it will only map a property to the target property only if the condition matches using the following scenario.

Scenario 1:

model.propA = 1

model.propB = 2


mappedProperty = 2

Scenario 2:

model.propA = 1

model.propB = null


mappedProperty = 1

You need to have a Set Expression on mappedProperty that contains the mapping logic for that property. Below is a sample Groovy snippet

model.propB ? model.propB : model.propA

The snippet follows the scenario you provided. It basically means if model.propB is not null or not empty, map model.propB to mapped property, else map model.propA