Package org.mapstruct.ap.spi
Interface EnumMappingStrategy
- All Known Implementing Classes:
DefaultEnumMappingStrategy
@Experimental("This SPI can have its signature changed in subsequent releases")
public interface EnumMappingStrategy
A service provider interface for the mapping between different enum constants
- Since:
- 1.4
- Author:
- Arne Seime, Filip Hrisafov
-
Method Summary
Modifier and TypeMethodDescriptiongetDefaultNullEnumConstant(TypeElement enumType) Return the default enum constant to use if the source is null.getEnumConstant(TypeElement enumType, String enumConstant) Map the enum constant to the value use for matching.Return the type element of the exception that should be used in the generated code for an unexpected enum constant.default voidinit(MapStructProcessingEnvironment processingEnvironment) Initializes the enum value mapping strategy
-
Method Details
-
init
Initializes the enum value mapping strategy- Parameters:
processingEnvironment- environment for facilities
-
getDefaultNullEnumConstant
Return the default enum constant to use if the source is null.- Parameters:
enumType- the enum- Returns:
- enum value or null if there is no designated enum constant
-
getEnumConstant
Map the enum constant to the value use for matching. In case you want this enum constant to match to null returnMappingConstants.NULL- Parameters:
enumType- the enum this constant belongs toenumConstant- constant to transform- Returns:
- the transformed constant - or the original value from the parameter if no transformation is needed. never return null
-
getUnexpectedValueMappingExceptionType
TypeElement getUnexpectedValueMappingExceptionType()Return the type element of the exception that should be used in the generated code for an unexpected enum constant.- Returns:
- the type element of the exception that should be used, never
null
-