BAEL-5977 Code for the Throw Exception for Unexpected Input for Enum with Mapstruct article
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.baeldung.enums;
|
||||
|
||||
enum InputLevel {
|
||||
|
||||
LOW, MEDIUM, HIGH
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.enums;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.mapstruct.ValueMapping;
|
||||
|
||||
@Mapper
|
||||
interface LevelMapper {
|
||||
|
||||
@ValueMapping(source = MappingConstants.ANY_REMAINING, target = MappingConstants.THROW_EXCEPTION)
|
||||
OutputLevel inputLevelToOutputLevel(InputLevel inputLevel);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.baeldung.enums;
|
||||
|
||||
enum OutputLevel {
|
||||
|
||||
LOW, HIGH
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user