check-fluent-setter-overrides.py
This script scans the Juneau codebase to find missing fluent setter overrides in subclasses.
Problem
Juneau uses fluent-style setters extensively for method chaining:
public class X {
public X setY(Y y) {
this.y = y;
return this;
}
}
When a class extends another class with fluent setters, it should override those setters to return the correct subclass type:
public class X2 extends X {
@Override
public X2 setY(Y y) {
super.setY(y);
return this;
}
}
What It Does
The script:
- Scans all Java files in the codebase
- Identifies classes with fluent setters
- Checks subclasses for proper overrides
- Reports missing or incorrect overrides
Usage
cd /Users/james.bognar/git/juneau
python3 scripts/check-fluent-setter-overrides.py
Requirements
- Python 3.6 or higher
- No external Python dependencies (uses only standard library)
Notes
- The script helps maintain type safety in fluent APIs
- Missing overrides can cause type casting issues in method chains
- Reports are printed to stdout with file locations and line numbers
Share feedback or follow-up questions for this page directly through GitHub.