Package org.mapstruct.ap.spi
Interface EnumMappingStrategy
-
- All Known Implementing Classes:
DefaultEnumMappingStrategy
@Experimental("This SPI can have it\'s signature changed in subsequent releases") public interface EnumMappingStrategy
A service provider interface for the mapping between different enum constants- Since:
- 1.4
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.StringgetDefaultNullEnumConstant(javax.lang.model.element.TypeElement enumType)Return the default enum constant to use if the source is null.java.lang.StringgetEnumConstant(javax.lang.model.element.TypeElement enumType, java.lang.String enumConstant)Map the enum constant to the value use for matching.javax.lang.model.element.TypeElementgetUnexpectedValueMappingExceptionType()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 Detail
-
init
default void init(MapStructProcessingEnvironment processingEnvironment)
Initializes the enum value mapping strategy- Parameters:
processingEnvironment- environment for facilities
-
getDefaultNullEnumConstant
java.lang.String getDefaultNullEnumConstant(javax.lang.model.element.TypeElement enumType)
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
java.lang.String getEnumConstant(javax.lang.model.element.TypeElement enumType, java.lang.String enumConstant)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
javax.lang.model.element.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
-
-