title: Using SuperBuilder to extend parent class using Lombok
body: <p>I had a DTO that was using Lombok functionaliy as shown below.But now due to some requirement I had to extend my DTO to a parent class which looks like below.How can I do minimal change in my DTO to support that.I tried using @SuperBuilder annotation but it failed.</p>
  <p>DTO Before:</p>
  <pre><code>@Getter
  @ToString
  @EqualsAndHashCode
  @Builder(toBuilder = true)
  @AllArgsConstructor(access = AccessLevel.PRIVATE)
  public class RequestMessage {
  private final String name;
   }
  </code></pre>
  <p>Parent Class that needs to be extended</p>
  <pre><code>   @Data
     @SuperBuilder(toBuilder = true)
     @JsonDeserialize(builder = MyDTO.Builder.class)
     public abstract class MyDTO implements Serializable {
     @JsonIgnore private final ObjectMapper objectMapper = new ObjectMapper();
     protected String myAccountId;
  
     protected MyDTO() {}
  
     public static int hashCode(Object... objects) {
       return Arrays.deepHashCode(objects);
     }
  
     public static boolean equal(Object o1, Object o2) {
      // implementation of equals method
     }
  
     public abstract String emitSerializedPayload() throws JsonProcessingException;
  
     @JsonPOJOBuilder(withPrefix = &quot;&quot;)
     protected abstract static class Builder&lt;T extends MyDTO, B extends Builder&lt;T, B&gt;&gt; {
     protected T dtoInstance;
     protected B builderInstance;
  
     public Builder() {
    dtoInstance = createDtoInstance();
    builderInstance = returnBuilderInstance();
  }
  
  protected abstract T createDtoInstance();
  
  protected abstract B returnBuilderInstance();
  
  public B myAccountId(String accountId) {
    dtoInstance.myAccountId = accountId;
    return builderInstance;
  }
  
  public T build() {
    return dtoInstance;
  }
  }
  }
  </code></pre>
  <p>I tried to build RequestMessageClass manually and it works fine but there are lot of classes in my application and I dont want to change them manually, how can I change my existing RequestMessage class with annotations or some minimum change to get it working.</p>
  <p>This is what I tried but I am getting compilation error when doing this</p>
  <pre><code>    RequestMessage.Builder().name(myName).myAccountId(myAcId).build();
       
       
  </code></pre>
  <p>What I tried is like shown below:</p>
  <pre><code> @Getter
   @ToString
   @EqualsAndHashCode(callSuper = true)
   @SuperBuilder(toBuilder = true)
   @AllArgsConstructor(access = AccessLevel.PRIVATE)
   public class RequestMessage extends MyDTO {
   private final String name;
  
   @Override
   public String emitSerializedPayload() throws JsonProcessingException {
  // TODO Auto-generated method stub
  return null;
  }
  } 
   
  </code></pre>