title: MapStruct : Conditional mapping of object property
body: <p>I am using mapstruct in springboot application for mapping StudentBean(source) to StudentDTO(target).
  I want to map properties on condition basis, conditions are as below :</p>
  <p><strong>Condition 1:</strong> If target(StudentDTO) property has value then don't map from source(StudentBean) property.</p>
  <p><strong>Condition 2:</strong> If source(StudentBean)property has value then only map into target(StudentDTO)else target value should not be updated.</p>
  <p>Source class as below :</p>
  <pre><code>StudentBean{
  String id;
  int marks;
  }
  </code></pre>
  <p>Target class as below :</p>
  <pre><code>StudentDTO{
  String id;
  int marks;
  }
  </code></pre>
  <p>Mapper class as below :</p>
  <pre><code>@Mapper
  Interface studentMapper{
  @mapping(target=&quot;id&quot;, source=&quot;id&quot;)// apply condition 1
  @mapping(target=&quot;marks&quot;, source=&quot;marks&quot;)// apply condition 2
  StudentDTO toDTO(StudentBean);
  }
  
  How to achieve this with mapstruct?
  
  </code></pre>