Package org.mapstruct.ap.spi
Class DefaultEnumMappingStrategy
- java.lang.Object
-
- org.mapstruct.ap.spi.DefaultEnumMappingStrategy
-
- All Implemented Interfaces:
EnumMappingStrategy
public class DefaultEnumMappingStrategy extends java.lang.Object implements EnumMappingStrategy
- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.lang.model.util.ElementselementUtilsprotected javax.lang.model.util.TypestypeUtils
-
Constructor Summary
Constructors Constructor Description DefaultEnumMappingStrategy()
-
Method Summary
All Methods Instance Methods Concrete 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.protected java.lang.Class<? extends java.lang.Exception>getUnexpectedValueMappingExceptionClass()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.voidinit(MapStructProcessingEnvironment processingEnvironment)Initializes the enum value mapping strategy
-
-
-
Method Detail
-
init
public void init(MapStructProcessingEnvironment processingEnvironment)
Description copied from interface:EnumMappingStrategyInitializes the enum value mapping strategy- Specified by:
initin interfaceEnumMappingStrategy- Parameters:
processingEnvironment- environment for facilities
-
getDefaultNullEnumConstant
public java.lang.String getDefaultNullEnumConstant(javax.lang.model.element.TypeElement enumType)
Description copied from interface:EnumMappingStrategyReturn the default enum constant to use if the source is null.- Specified by:
getDefaultNullEnumConstantin interfaceEnumMappingStrategy- Parameters:
enumType- the enum- Returns:
- enum value or null if there is no designated enum constant
-
getEnumConstant
public java.lang.String getEnumConstant(javax.lang.model.element.TypeElement enumType, java.lang.String enumConstant)Description copied from interface:EnumMappingStrategyMap the enum constant to the value use for matching. In case you want this enum constant to match to null returnMappingConstants.NULL- Specified by:
getEnumConstantin interfaceEnumMappingStrategy- 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
public javax.lang.model.element.TypeElement getUnexpectedValueMappingExceptionType()
Description copied from interface:EnumMappingStrategyReturn the type element of the exception that should be used in the generated code for an unexpected enum constant.- Specified by:
getUnexpectedValueMappingExceptionTypein interfaceEnumMappingStrategy- Returns:
- the type element of the exception that should be used, never
null
-
getUnexpectedValueMappingExceptionClass
protected java.lang.Class<? extends java.lang.Exception> getUnexpectedValueMappingExceptionClass()
-
-