Claybrooks28kcz
New Member
I have such enum:\[code\]public enum PartnershipIndicator { VENDOR("VENDOR"), COPARTNER("COPARTNER"), BUYER("BUYER"); String code; private PartnershipIndicator(String code) { this.code = code; } public String getCode() { return code; } public static PartnershipIndicator valueOfCode(String code) { for (PartnershipIndicator status : values()) { if (status.getCode().equals(code)) { return status; } } throw new IllegalArgumentException( "Partnership status cannot be resolved for code " + code); } @Override public String toString() { return code; }}\[/code\]I need to convert it to String and vice versa. Now, it is done by custom converter. But i want to do it via dozer mappings (if it is possible). If i do not write any mappings to the dozer confing, i get\[code\]org.dozer.MappingException: java.lang.NoSuchMethodException: by.dev.madhead.demo.test_java.model.PartnershipIndicator.<init>()\[/code\]exception. I cannot add default public constructor to enum, as it is not possible. So, i wrote a trick with internal code and valueOfCode() / toString(). It does not work. Then, i've mapped it in dozer config:\[code\]<mapping> <class-a>java.lang.String</class-a> <class-b create-method="valueOfCode">by.dev.madhead.demo.test_java.model.PartnershipIndicator</class-b></mapping>\[/code\]It does not work. I tried valueOfCode(), one-way mappings. Nothing works. Enum to String conversion does not work too, i get empty Strings.Any ideas?