Die Java-enum erweitert workaround

Gibt es eine bessere "workaround" als dieses? Ich möchte vermeiden, die Verwendung eines PRÄFIX (local var) beim Zugriff auf die Methoden, die auf TableMap.

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(){}
    ...
}

workaround!

public enum Tables {
    table1, table2, table3;
    public final TableMap MAP=new TableMap(this);
    private Tables(){}
}

benötigt!

public enum Tables extends TableMap {
    table1, table2, table3;
    public Tables(){
        super(table);
    }
}

Beispiel in dem gesamten code:

    //workaround!
    Tables.table1.MAP.method();
    Tables.table2.MAP.method();
    Tables.table3.MAP.method();
    ...

    //needed!
    Tables.table1.method();
    Tables.table2.method();
    Tables.table3.method();
    ...
  • Die Frage (während zu sein scheint, ein wertvolles, gut), ist ein wenig unklar, fügen Sie bitte mehr Kontext.
InformationsquelleAutor marcolopes | 2013-10-03
Schreibe einen Kommentar