Files
VV-ISTIC-TP2/exercises/no-getter.md
Romain Lefeuvre 7b185c9c0c 2025 init
2025-11-18 14:41:54 +01:00

1.2 KiB

No getter!

With the help of JavaParser implement a program that obtains the private fields of public classes that have no public getter in a Java project.

A field has a public getter if, in the same class, there is a public method that simply returns the value of the field and whose name is get<name-of-the-field>.

For example, in the following class:


class Person {
    private int age;
    private String name;
    
    public String getName() { return name; }

    public boolean isAdult() {
        return age > 17;
    }
}

name has a public getter, while age doesn't.

The program should take as input the path to the source code of the project. It should produce a report in the format of your choice (TXT, CSV, Markdown, HTML, etc.) that lists for each detected field: its name, the name of the declaring class and the package of the declaring class.

Include in this repository the code of your application. Remove all unnecessary files like compiled binaries. See the instructions for suggestions on the projects to use.

Disclaimer In a real project not all fields need to be accessed with a public getter.