无法在代码模型中创建摘要 class?
Cannot create abstract class in codemodel?
我的代码:
JCodeModel cm = new JCodeModel();
cm._class(JMod.ABSTRACT, "TestClass", ClassType.CLASS);
cm.build(new File("."));
无论我向 mods
或 ClassType
参数写入什么,结果始终是 public class
.
如何创建摘要class?
奇怪。似乎 JCodeModel 没有包就不会创建抽象 类 。以下情况有包声明:
JCodeModel cm = new JCodeModel();
cm._class(JMod.PUBLIC | JMod.ABSTRACT, "test.TestClass", ClassType.CLASS);
cm.build(new File("."));
生成:
package test;
public abstract class TestClass {
}
或
JCodeModel cm = new JCodeModel();
JPackage pkg = cm._package("");
pkg._class(JMod.ABSTRACT, "TestClass2", ClassType.CLASS);
cm.build(new File("."));
生成:
public abstract class TestClass2 {
}
我的代码:
JCodeModel cm = new JCodeModel();
cm._class(JMod.ABSTRACT, "TestClass", ClassType.CLASS);
cm.build(new File("."));
无论我向 mods
或 ClassType
参数写入什么,结果始终是 public class
.
如何创建摘要class?
奇怪。似乎 JCodeModel 没有包就不会创建抽象 类 。以下情况有包声明:
JCodeModel cm = new JCodeModel();
cm._class(JMod.PUBLIC | JMod.ABSTRACT, "test.TestClass", ClassType.CLASS);
cm.build(new File("."));
生成:
package test;
public abstract class TestClass {
}
或
JCodeModel cm = new JCodeModel();
JPackage pkg = cm._package("");
pkg._class(JMod.ABSTRACT, "TestClass2", ClassType.CLASS);
cm.build(new File("."));
生成:
public abstract class TestClass2 {
}