0

I am using freemaker to generate dto convertor from one type to another. Defining things through custom annotations E.g:

@CustomAnnotationTargetDTO(type=DTO2)
Class DTO1 {

@CustomAnnotationTargetProperty(propertyName="gender")
private String sex;

}

like this I have invented different annotations that I use to map a class and its properties to other type.

I now have a Enumeration in a DTO. Any idea on the similar lines that how i map 1 type to another.

I was thinking on the lines

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

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

}
Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
S Kr
  • 1,831
  • 2
  • 25
  • 50
  • So, what's the question? Where's the problem? – Thomas Aug 23 '12 at 11:08
  • Turns out i can do something like this String field = Type1Enum.FEMALE.toString(); Type1Enum.class.getField(field).getAnnotation(CustomAnnotationTargetEnumValue.class); – S Kr Aug 23 '12 at 13:20

0 Answers0