コード モデルを使用してコードにクラスをインポートしようとしています。これは私のコードです。
JCodeModel model = new JCodeModel();
JClass mapper = model.directClass("com.another.Mapper");
JDefinedClass dc = model._class("com.example.Something");
JMethod method = dc.method(JMod.PUBLIC | JMod.STATIC, Void.TYPE,
"testMethod");
JBlock executerBlock = method.body();
executerBlock.directStatement("Mapper.get()");
File file = new File("./src");
file.mkdirs();
model.build(file);
今、結果として次のクラスを取得しています。
package com.example;
public class Something {
public static void testMethod() {
Mapper.get()
}
}
しかし、実際に必要なのは、
package com.example;
import com.another.Mapper;
public class Something {
public static void testMethod() {
Mapper.get()
}
}
使わないと輸入が来ません。このインポートを行うにはどうすればよいですか。