I'm using Eclipse with Lombok. The getters and setters are generated properly but they are not visible in class body (that's the whole point, I know). However, because of that, I am unable to execute a search for usages of a getter or a setter from inside the class. So if I want to check what and where actually sets a particular value of a field, I have to execute a String search for the getter name, which is slow and may give bad results (for a field of the same name in another class, for example).
Is there a way in Eclipse to look for a getter/setter usage for a field for lombok-generated methods?
You can annotate any field with @Getter and/or @Setter , to let lombok generate the default getter/setter automatically. A default getter simply returns the field, and is named getFoo if the field is called foo (or isFoo if the field's type is boolean ).
Getters and setters are used to protect your data, particularly when creating classes. For each instance variable, a getter method returns its value while a setter method sets or updates its value. Given this, getters and setters are also known as accessors and mutators, respectively.
@Data is a convenient shortcut annotation that bundles the features of @ToString , @EqualsAndHashCode , @Getter / @Setter and @RequiredArgsConstructor together: In other words, @Data generates all the boilerplate that is normally associated with simple POJOs (Plain Old Java Objects) and beans: getters for all fields, ...
You can use the Outline view:
Right-click on the method in the Outline view, and use "Open Call Hierarchy".
An other way to do it is to right-click on the annotation (@Setter
for instance), and use "Open Call Hierarchy" on it, but it may not work with some annotations (like @Data
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With