September 2019
Intermediate to advanced
816 pages
18h 47m
English
Let's assume that Melon has three fields (type, weight, and ripe) and defines only a getter for type and a setter for ripe:
public class Melon { private String type; private int weight; private boolean ripe; ... public String getType() { return type; } public void setRipe(boolean ripe) { this.ripe = ripe; } ...}
In order to generate the missing getters and setters, we start by identifying them. The following solution loops the declared fields of the given class and assumes that a foo field doesn't have a getter if the following apply:
For each missing getter, this solution adds in a map an entry ...