我正在尝试使用xtend框架生成以下Java代码
http://www.eclipse.org/xtend/
class COMPLEYTYPENAMESerializer {
static void serialize(IObjectName objectToSerialze, OutputByteStream outPutStream){
// some code will be here
}
static void dezerialize(IModifyNetModel modifyNetModel, InputByteStream inputStream){
// some code will be here
}
}
class NetModelSerialize {
sTATIC void serialize(IQueryNetModel,...) {
// some code will be here
}
static void dezerialize(IModifyNetModel modifyNetModel,...){
// some code will be here
}
}
我需要在一个单独的文件中生成每个类,并将两者都放在同一包中。
到目前为止,这是我在xtend中完成的工作
def compile(StreamGeneratorData genData) '''
«GeneratorUtils.compilePackage(genData.getPackageBase, Constants.MODULE_NAME)»
«compileImports(genData)»
public class «genData.className»COMPLEYTYPENAMESerializer «IF genData.baseClassName.length > 0
»extends «genData.baseClassName» «ENDIF»{
«compileSerialize()»
«compileDezerialize()»
}
public class «genData.className»NetModelSerialize «IF genData.baseClassName.length > 0
»extends «genData.baseClassName» «ENDIF»{
«compileNetModelSerialize()»
«compileNetModelDezerialize()»
}
'''
最佳答案
您不能使用一个Xtend文件生成2个Java类,您必须为要生成的每个java类编写单独的xtend文件
关于java - 如何使用Xtend框架生成2个Java类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50627572/