Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用freemaker向另一个dto转换器生成1个dto。在生成枚举类型1到枚举类型2转换器时卡住_Java_Enums_Converter_Freemarker_Generated Code - Fatal编程技术网

Java 使用freemaker向另一个dto转换器生成1个dto。在生成枚举类型1到枚举类型2转换器时卡住

Java 使用freemaker向另一个dto转换器生成1个dto。在生成枚举类型1到枚举类型2转换器时卡住,java,enums,converter,freemarker,generated-code,Java,Enums,Converter,Freemarker,Generated Code,我使用freemaker生成从一种类型到另一种类型的dto转换器。通过自定义注释定义事物 例如: 像这样,我发明了不同的注释,用于将类及其属性映射到其他类型 我现在在DTO中有一个枚举。关于我如何将一种类型映射到另一种类型的类似行的任何想法 我在想台词 @CustomAnnotationTargetEnum(xmlEnum="Type2Enum") public enum Type1Enum { @CustomAnnotationTargetEnumValue(enumValue="G

我使用freemaker生成从一种类型到另一种类型的dto转换器。通过自定义注释定义事物 例如:

像这样,我发明了不同的注释,用于将类及其属性映射到其他类型

我现在在DTO中有一个枚举。关于我如何将一种类型映射到另一种类型的类似行的任何想法

我在想台词

@CustomAnnotationTargetEnum(xmlEnum="Type2Enum")
public enum Type1Enum {

    @CustomAnnotationTargetEnumValue(enumValue="GIRL")
    FEMALE(Byte.valueOf("1")), 
    @CustomAnnotationTargetEnumValue(enumValue="BOY")
    MALE(Byte.valueOf("2"));
//other stuff below

}

那么,问题是什么?问题出在哪里了?原来我可以做类似以下的事情:字符串字段=type1num.FEMALE.toString();Type1Enum.class.getField(field).getAnnotation(CustomAnnotationTargetEnumValue.class);
@CustomAnnotationTargetEnum(xmlEnum="Type2Enum")
public enum Type1Enum {

    @CustomAnnotationTargetEnumValue(enumValue="GIRL")
    FEMALE(Byte.valueOf("1")), 
    @CustomAnnotationTargetEnumValue(enumValue="BOY")
    MALE(Byte.valueOf("2"));
//other stuff below

}