龙目岛自定义超级建筑
我有两个这样的类:
@Builder
public class Parent {
final int a;
final int b;
public class static ParentBuilder {
public ParentBuilder setAllTo(final int value) {
return a(value).b(value);
}
}
}
public class Child extends Parent {
final in c;
@Builder(builderMethodName = "childBuilder")
public Child(final int a, final int b, final int c) {
super(a, b);
this.c = c;
}
}
我的班级正在成长,拥有越来越多的领域。这是一个使用.但是,如何添加自定义的生成器方法?@SuperBuilder
同样的工作方式。我试过这种方式:
@SuperBuilder
public abstract class Parent { //yes, I want a abstract parent
final int a;
final int b;
public class static ParentBuilder {
public ParentBuilder setAllTo(final int value) {
return a(value).b(value);
}
}
}
@SuperBuilder
public class Child extends Parent {
final in c;
}
编辑
这还不可能。当我尝试以相同的方式执行此操作时,我得到了一个例外:
重写是一个内部类,如下所示:@SuperBuilder does not support customized builders. Use @Builder instead.
public abstract static class ParentBuilder<C extends ParentBuilder, B extends Parent.ParentBuilder<C, B>> {
// custom imlementations here
}