I have a field I want getters & setters for. The problem is that the field should be capitalized if it is occuring after the position in any field or method.
ex:
What I get
private final String url;
// auto - lombok
public String getUrl() {...};
public void setUrl(String url) {...};
What I want
private final String url;
// auto - lombok
public String getURL() {...};
public void setURL(String url) {...};
As additional context, the class is decorated with @Data
and there are only few fields I need this behaviour for.
Lombok only modifies the capitalization of the first letter:
For generating the method names, the first character of the field, if it is a lowercase character, is title-cased, otherwise, it is left unmodified. Then, get/set/is is prefixed.
So you could technically rename your field to URL, but it'd violate the ALL_CAPS static final
variable name convention.
Or you can just make a getter yourself and disable the auto-generated getter, assuming you're using something like @Data
:
@Getter(AccessLevel.NONE)
private final String url;
public String getURL() {
return url;
}