@Data does not generates getters and setters for variable with $ in name

60 views
Skip to first unread message

Oleg Ciornei

unread,
Oct 28, 2022, 11:54:55 AM10/28/22
to Project Lombok
I have variable with $ in name: 
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Property {
private String type;
private String description;
private String format;
private String example;
private Object xml;
private List<Object> items;
private List<String> ENUM;
private String $ref;
}

no getters and setters are generated for $ref

like this it works:
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Property {
private String type;
private String description;
private String format;
private String example;
private Object xml;
private List<Object> items;
private List<String> ENUM;
private String $ref;

public String get$ref() {
return $ref;
}

public void set$ref(String $ref) {
this.$ref = $ref;
}
}

Reinier Zwitserloot

unread,
Nov 12, 2022, 11:45:15 AM11/12/22
to Project Lombok
This is intentional. By convention, $ means: This is generated or otherwise special. I think you can get around it by slapping a `@Getter` on the field specifically, or a `@ToString.Include` on it, for example.
Reply all
Reply to author
Forward
0 new messages