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