lombok SuperBuilder to set default value

Viewed 286

Hi I'm using lombok SuperBuilder on inherent class. The code looks like:

@SuperBuilder(toBuilder = true)
class SomeClass extends Parent {
    private xxxx fieldA;
    @Builder.Default
    private Function fieldB = input -> {
        fieldA.xxxx
    };
}

I'm trying to set a function as default value for fieldB. And there is a reference of fieldA.

There will be an error when building saying 'non-static field fieldA cannot be referenced from a static context'

Seems the root cause is lombok trying to build a static builder. Could you please help figure this out? Thank you !

0 Answers
Related