有没有办法“继承”进口?
例:
普通枚举:
public enum Constant{ ONE, TWO, THREE }
使用此枚举的基类:
public class Base {
protected void register(Constant c, String t) {
...
}
}
子类需要导入使用枚举常数方便(不含枚举名称):
import static Constant.*; // want to avoid this line!
public Sub extends Base {
public Sub() {
register(TWO, "blabla"); // without import: Constant.TWO
}
}
和另一个类有相同的进口…
import static Constant.*; // want to avoid this line!
public AnotherSub extends Base {
...
}
我可以使用经典的静态最终常量,但也许有一种方法可以使用相同的方便的常见枚举.