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 Detail

      • init

        default void init​(MapStructProcessingEnvironment processingEnvironment)
        Initializes the enum value mapping strategy
        Parameters:
        processingEnvironment - environment for facilities
      • getDefaultNullEnumConstant

        String getDefaultNullEnumConstant​(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

        String getEnumConstant​(TypeElement enumType,
                               String enumConstant)
        Map the enum constant to the value use for matching. In case you want this enum constant to match to null return MappingConstants.NULL
        Parameters:
        enumType - the enum this constant belongs to
        enumConstant - 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