When I do quick fix on a field in eclipse I can generate a getter and setter for the field. This also makes the field private und subsequently transforms all access for this field in all source files to use the getter and setter. This is the case for a single field.
However if I do contextmenu > Source > Generate Getters and Setters... (the option to use when you want to affect all fields) it does not make the beforementioned change and all access to the fields in the source code is left as is.
Am I overlooking something?
Encapsulation in Java – Hiding the variables of a class from other classes, and giving access to them only through methods(setters and getters). Hence, Encapsulation in Java language means binding the data (variables) with the code(methods – setters and getters).
An Eclipse plugin which generates Javadoc for getters and setters of a Java class. The generated Javadocs are based on those of fields corresponding to the getters or setters.
Having getters and setters does not in itself break encapsulation.
The quick fix is not going to this menu. The menu that the quick fix call is accessible from Context Menu -> Refactor -> Encapsulate Field
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