Reputation: 639
For example:
class a {
int field1;
int field2;
public a(int field1, int field2){ this.field1 = field1; this.field2 = field2;}
void setField1(int field1) {this.field1 = field1;}
void setField2(int field2) {this.field2 = field2;}
}
Sometimes when i create an instance, i need to set both parameters, and sometimes i need to change some values, so i need both setters and constructor. Why does SONAR marks this as duplicate? Is there only option is to tell sonar not to scan enitity files or there is a better way to solve this?
Upvotes: 3
Views: 435
Reputation: 1277
Try Lombok: https://projectlombok.org/setup/maven, a simple annotation @Data
for your class definition will remove your code boilerplate (getter/setter/constructor/etc.).
Upvotes: 1