java - unable to generate mapping method from Enum To Boolean by MapStruct -


i can use succesfully enum enum using mapstruct converts 1 object type object type.

unfortunately, not able convert enum boolaen. following error.

"can't map property "choicetype ispricehigh" "java.lang.boolean ispricehigh". consider declare/implement mapping method: "java.lang.boolean map(choicetype value)".

here method use @ mapstruct. appreciated.

cheers alper

@valuemappings({         @valuemapping(target = "true", source = "yes"),         @valuemapping(target = "false", source = "no") }) boolean map(choicetype value); 

@valuemappings can used map between enum(s) , not object , enum. boolean in java not enum , reason why getting error.

in order such mapping have define own method it.

public interface mymapper {      default boolean map(choicetype value) {         if (value == null) {             return null;         }          switch(value) {             case yes:                 return true;             case no:             default:                 return false;         }     } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -