title: Repetition in Builder Pattern
body: <p>I'm using a builder pattern (as explained in Joshua Bloch's <code>Effective Java</code>) for a few things, and there's a particularly annoying repetition involved:</p>
  
  <pre><code>public class Foo {
      private String name;
      private int age;
  
      public static class Builder implements IBuilder {
          private String name;
          private int age;
  
          Builder name(String value) {
              name = value;
              return this;
          }
  
          Builder age(int value) {
              age = value;
              return this;
          }
  
          Foo build() {
             return new Foo(this);
          }
      }
  
      private Foo(Builder builder) {
          name = builder.name;
          age = builder.age;
      }
  }
  </code></pre>
  
  <p>It's small, but annoying. I have to declare the variable in each class. I tried creating a class with the fields and extending that class, but I got the error: <code>{variable_name} has private access in {class_name}</code>.</p>
  
  <p>Is there a way to do this, without making the variables public?</p>