I\'d like to do the following:
public class Sub extends Super {
public Sub(Super underlying) {
if (underlying == null) {
underlying = super; // this
It looks like you want to implement the delegation pattern.
Simple extend Super, and let your IDE override all methods with the creation of super calls.
Then replace "super." with "underlying."
Error prone, but that's it.
public class Sub extends Super {
Super underlying;
public Sub(Super underlying) {
this.underlying = underlying;
}
@Override
public void f() {
underlying.f();
}