title: Map null values to default using builder with MapStruct
body: <p>I want to map field from <code>Source</code> to <code>Target</code> class, and if the source value is <code>null</code>, I would like to convert it to default value based on  the data type (&quot;&quot; for strings, 0 for numeric types etc.). For setting the values, I am not using regular setters, but builder (with <a href="https://developers.google.com/protocol-buffers" rel="nofollow noreferrer">protobuf</a>, so the names of the methods is <code>newBuilder()</code> and <code>build()</code>).</p>
  <pre><code>class Source {
      private final String value; // getter
  }
  
  class Target {
      private final String value;
  
      public static Builder newBuilder() {return new Builder()}
  
      public static class Builder {
          public static setValue() {/*Set the field*/}
          public static Target build() {/*Return the constructed instance*/}
  }
  </code></pre>
  <p>My mapper looks like this:</p>
  <pre><code>@Mapper(
      nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.SET_TO_DEFAULT,
      nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT
  )
  public interface TargetMapper {
      Target map(Source source);
  }
  </code></pre>
  <p>The generated mapper implementation with this code calls <code>target.setValue(source.getValue())</code>, instead of performing the null check and setting default value if source returns <code>null</code>. The interesting part is when I add the following annotation to the <code>map</code> method, the null check is present in the implementation.</p>
  <pre><code>@Mapping(source=&quot;value&quot;, target=&quot;value&quot;, nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.SET_TO_DEFAULT)
  </code></pre>
  <p>Is this a bug in MapStruct with builders, or am I missing some configuration to be ably to set the null mapping as a default policy, instead of duplicating it on all field mappings?</p>
  <p>EDIT: For some reason, adding <code>nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS</code> to the class level <code>@Mapper</code> annotation adds the null check, but does not explicitly set the value, just skips the call to <code>setValue</code>. For protobuf, this is okay, since this functionality is in the library, but for other implementations the field would remain null.</p>