I have a class with lombok's @Data
and @AllArgsConstructor(access = AccessLevel.PUBLIC)
:
@Data
@AllArgsConstructor(access = AccessLevel.PUBLIC)
public class ResponseVO implements Serializable {
private static final long serialVersionUID = 3461582576096529916L;
@JacksonXmlProperty(localName = "amount", isAttribute = true)
String amount;
}
When I'm using the constructor
new ResponseVO("22222");
I'm getting a warning inside tooltip when hovering over constructor method:
ResponseVO.ResponseVO(String amount)
@SuppressWarnings(value={"all"})
Why this warning added ? without @Data
it disappears
Class decompile without any warnings:
public class ResponseVO implements Serializable {
private static final long serialVersionUID = 3461582576096529916L;
@JacksonXmlProperty(localName = "amount", isAttribute = true)
String amount;
public String getAmount() {
return this.amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof ResponseVO)) {
return false;
} else {
ResponseVO other = (ResponseVO) o;
if (!other.canEqual(this)) {
return false;
} else {
String this$amount = this.getAmount();
String other$amount = other.getAmount();
if (this$amount == null) {
if (other$amount != null) {
return false;
}
} else if (!this$amount.equals(other$amount)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof ResponseVO;
}
public int hashCode() {
boolean PRIME = true;
byte result = 1;
String $amount = this.getAmount();
int result1 = result * 59 + ($amount == null ? 43 : $amount.hashCode());
return result1;
}
public String toString() {
return "ResponseVO(amount=" + this.getAmount() + ")";
}
public ResponseVO(String amount) {
this.amount = amount;
}
}
This is not a warning, it is the regular Eclipse tooltip which appears on all classes, methods etc. Those tooltips show the JavaDoc of the respective element (which is empty in this case) and also list all annotations on the element.
And this is why you see the @SuppressWarnings
: It is generated by Lombok to avoid that the compiler emits warnings on Lombok generated code.
The question remains why Lombok would generated those suppression annotations.
Typically, Lombok's code will not produce any warnings. However, new Java language or compiler versions may result in new types of warnings or new deprecations. Running a non-adapted Lombok version targeting a newer Java version therefore may produce warnings. As users will not be able to fix those warnings, those warnings are suppressed.
Furthermore, adding @SuppressWarnings("all")
also suppresses non-standard warnings, e.g. from code linters or in code analysis integrated in IDEs like IntelliJ IDEA.