これよりも優れた「回避策」はありますか?TableMap のメソッドにアクセスするときに、PREFIX (ローカル変数) の使用を避けたいと考えています。
public class TableMap extends TreeMap<String, String> {
public String field1, field2, field3;
public TableMap(Tables table){}
public void method(){}
public void method2(){}
public void method3(){}
...
}
回避策!
public enum Tables {
table1, table2, table3;
public final TableMap MAP=new TableMap(this);
private Tables(){}
}
必要です!
public enum Tables extends TableMap {
table1, table2, table3;
public Tables(){
super(table);
}
}
コード全体の例:
// workaround!
Tables.table1.MAP.method();
Tables.table2.MAP.method();
Tables.table3.MAP.method();
...
// needed!
Tables.table1.method();
Tables.table2.method();
Tables.table3.method();
...