title: How do I use lombok @Builder to store different values?
body: <p>I have the following JPA entity</p>
  
  <pre><code>@Data
  @Builder
  public class Post {
    @Id
    @GeneratedValue
    UUID id;
  
    @OneToMany
    Set&lt;PostTags&gt; tags;
  
    String content;
  }
  
  @Data
  public class PostTag {
    @Id
    @GeneratedValue
    UUID id;
  
    @OneToOne
    Post post;
  
    String tag;
  }
  </code></pre>
  
  <p>Using lombok @Builder I want to be able to do the following</p>
  
  <pre><code>Post post = Post.builder()
    .tags("hello", "world")
    .content("Hello world")
    .build();
  </code></pre>
  
  <p>I am presuming I need a custom builder along the lines of</p>
  
  <pre><code>public static class PostBuilder {
    private Set&lt;String&gt; myTags = new HashSet&lt;&gt;();
    public PostBuilder tags(String... tags) {
      myTags.addAll(Arrays.asList(tags));
      return this;
    }
  }
  </code></pre>
  
  <p>From the <a href="https://www.projectlombok.org/features/Builder" rel="nofollow noreferrer">documentation</a> it appears there <code>ObtainVia</code> annotation that I can use, but I am not sure how to get around it (no example on the doc) and especially since I only want <code>myTags</code> to be a builder specific thing, and not be exposed on the main class itself.</p>