title: Create new object with Builder pattern with "old" object reference
body: <p>I am playing around with the Builder pattern and get stuck how to add a new "property" to a new-created object:</p>
  
  <pre><code>public class MsProjectTaskData {
    private boolean isAlreadyTransfered;
    private String req;    
  
     public static class Builder {    
      private boolean isAlreadyTransfered = false;
  
      public Builder withTransfered(boolean val) {
          isAlreadyTransfered = val; 
          return this;
      }    
      public MsProjectTaskData build() {
          return new MsProjectTaskData(this);
      }
     }
  
     private MsProjectTaskData(Builder builder) {
       isAlreadyTransfered = builder.isAlreadyTransfered;
     }
  
    public MsProjectTaskData(String req) {
      this.req = req;
    }
  }
  </code></pre>
  
  <p>I can create a new object with Builder like this:</p>
  
  <pre><code>MsProjectTaskData data = new MsProjectTaskData.Builder().withTransfered(true).build();
  </code></pre>
  
  <p>But with this approach the <code>req</code> string from a new-created object is lost (of course). </p>
  
  <p>Is there a possibility to create a new object with the new set <code>isAlreadyTransfered</code> variable and <strong>with the "old" <code>req</code> string from a "old" object?</strong></p>
  
  <p>Maybe I have to pass the old object reference to the Builder but I do not know how to do this. Maybe the use of Builder pattern is not really usefull for this approach?</p>
  
  <p><strong>EDIT: (After comment from Eugene)</strong></p>
  
  <p>Think, I got it:</p>
  
  <pre><code>public static class Builder {   
   private boolean isAlreadyTransfered = false;
   private MsProjectTaskData data;
  
   public Builder(MsProjectTaskData data) {
       this.data = data;
   }
  
   public Builder withTransfered(boolean val) {
       isAlreadyTransfered = val; 
       data.setAlreadyTransfered(isAlreadyTransfered);
       return this;
   }   
   public MsProjectTaskData build() {
       return data;
   }
  }
  </code></pre>
  
  <p>Seems to work or is something wrong with the code above? Can I use this approach without consideration?</p>