vendredi 10 juin 2016

Inheritance for builders in lombok

I was trying to use lombok for my project.

I have a class A:

@Data
@Builder
public class A {
    Integer a1;
}

and a class B:

@Data
public class B extends A {
    Integer b1;

    @Builder
    public B(Integer b1, Integer a1) {
        super(a1);
        this.b1 = b1;
    }
}

I am getting an error saying builder() in B cannot override builder() in A, as return type in BBuilder is not compatible with return type in ABuilder.

Is there some way to do this using lombok? I do not want to write the complete builder for for B, unless I dont have any other option.

PS: I have given explicit constructor for class B due to Issue. I tried searching, but I could not find a good solution for the same. Any help is really appreciated.

Aucun commentaire:

Enregistrer un commentaire