title: mapstruct: How to construct a string from an object's property in mapstruct?
body: <p>I have the below class structure.</p>
  
  <pre><code>public class Comment
  {
    private Integer id;
    private String text;
  
    //getters &amp; setters
  }
  
  @Mapper(componentModel = "spring")
  public interface CommentMapper
  {
      String map(Comment comment);
      Comment map(String text);
      //Comment map(String someNameHere);
  }
  </code></pre>
  
  <p>The below is the implementation generated by mapstruct</p>
  
  <pre><code>@Override
  public String map(Comment comment) {
  if ( comment == null ) {
      return null;
  }
  String string = new String();
  return string;
  }
  
  @Override
  public Comment map(String text) {
  if ( text == null ) {
      return null;
  }
  Comment comment = new Comment();
  comment.setText( text );
  return comment;
  }
  
  /*
  @Override
  public Comment map(String someNameHere) {
      if ( someNameHere == null ) {
          return null;
      }
      Comment comment = new Comment();
      return comment;
  }
  */
  </code></pre>
  
  <p>Question1:
  The <code>map</code> method which takes the <code>Comment</code> object as parameter and returns the string is just returning an empty string object instead of setting the <code>text</code> property on the string and return it. Why? and how to get the <code>text</code> property of the <code>comment</code> object returned?</p>
  
  <p>Question2:
  when the parameter name of the map method is <code>text</code> it generates implementation utilizing the <code>text</code> property from the class or else just empty <code>comment</code> object. I really surprised to see that mapstruct generates different implementations depends on the parameter name too. Any explanation?</p>
  
  <p>Note:
  The <code>Comment</code> object is used as a property inside another object. There i need the above mentioned behavior. For now i managing it this way.
  @Mapping(source = "entity.comment.text", target = "comment")
  @Mapping(source = "dto.comment", target = "comment.text")</p>