variable injection
たぶん発想がアフォすぎて誰も手を出さなかったinjection.
public class Hoge { @Injection private static final String[] FOO = {"dummy"}; public static void main(String[] args) { @Injection int bar = 0; System.out.println(FOO[bar]); } }
annotation ? name Injection annotates ?f, ?lv class ?c name Hoge declares ?f declares main as ?m method ?m declares ?lv apply(?c, ?f, ?lv) void process(ASTClass c, ASTVariable f, ASTVariable lv) { f.getRhs().replace(new String[]{"a", "b", "c"}); lv.getRhs().replace(1); c.deploy(); }
setterでやると不変クラス作るのが大変なので、漢らしくこういうところでいじりたい。
テスト用モックにインジェクションするとなぜか成果物になってました的な。
まぁ、まだ上のやつは色々問題がありますがこの辺で。