如何在lombok中自定义一个方法名
How to customize a method name in lombok
有谁知道如何change/customize lombok 中的方法名称?
比如我想把名字getContributionType()
改成getType()
:
@Getter
@Setter
private String contributionType;
当我要获取贡献类型时,方法名称将是getContributionType()
。但我想将其更改为:
private String contributionType;
public String getType() {
return contributionType;
}
public void setType(final String type) {
this.contributionType = type;
}
一般来说,您不能使用 Lombok 重命名这些方法。但是你可以告诉它 strip prefixes 这可能适用于你的情况,尽管它不是为切断整个单词而设计的 :).
@Getter
@Setter
@Accessors(prefix="contribution")
private String contributionType;
有谁知道如何change/customize lombok 中的方法名称?
比如我想把名字getContributionType()
改成getType()
:
@Getter
@Setter
private String contributionType;
当我要获取贡献类型时,方法名称将是getContributionType()
。但我想将其更改为:
private String contributionType;
public String getType() {
return contributionType;
}
public void setType(final String type) {
this.contributionType = type;
}
一般来说,您不能使用 Lombok 重命名这些方法。但是你可以告诉它 strip prefixes 这可能适用于你的情况,尽管它不是为切断整个单词而设计的 :).
@Getter
@Setter
@Accessors(prefix="contribution")
private String contributionType;