龍目島在自動生成構造函數時忽略字段的註釋。有沒有辦法在構造函數輸入參數中保留字段的註解?龍目島 - 在構造函數輸入參數中保留字段註釋
類生成構造函數,
@RequiredArgsConstructor(onConstructor = @__(@Inject))
public class Test {
@Named("MyField")
private final String field;
@Named("MyHandler")
private final SomeHandler handler;
}
生成類:
public class Test {
@Named("MyField")
private final String field;
@Named("MyField")
private final SomeHandler handler;
@Inject
public Test(final String field, final SomeHandler handler) {
this.field = field;
this.handler = handler;
}
}
所需類:
public class Test {
@Named("MyField")
private final String field;
@Named("MyHandler")
private final SomeHandler handler;
@Inject
public Test(@Named("MyField")final String field,
@Named("MyHandler")final SomeHandler handler) {
this.field = field;
this.handler = handler;
}
}
我不認爲這是按照實施:https://groups.google.com/forum/#!topic/project-lombok/2vaujDkV8Nw – Cheetah
@Cheetah我很害怕,你說得對。幾年前我開始實施它,但比我想象的要複雜。沒有人在乎,我發現我自己很少需要它,並且有一個解決方法。 – maaartinus