Class DefaultEnumMappingStrategy

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.lang.model.util.Elements elementUtils  
      protected javax.lang.model.util.Types typeUtils  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDefaultNullEnumConstant​(javax.lang.model.element.TypeElement enumType)
      Return the default enum constant to use if the source is null.
      java.lang.String getEnumConstant​(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.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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • elementUtils

        protected javax.lang.model.util.Elements elementUtils
      • typeUtils

        protected javax.lang.model.util.Types typeUtils
    • Constructor Detail

      • DefaultEnumMappingStrategy

        public DefaultEnumMappingStrategy()
    • Method Detail

      • getDefaultNullEnumConstant

        public java.lang.String getDefaultNullEnumConstant​(javax.lang.model.element.TypeElement enumType)
        Description copied from interface: EnumMappingStrategy
        Return the default enum constant to use if the source is null.
        Specified by:
        getDefaultNullEnumConstant in interface EnumMappingStrategy
        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: EnumMappingStrategy
        Map the enum constant to the value use for matching. In case you want this enum constant to match to null return MappingConstants.NULL
        Specified by:
        getEnumConstant in interface EnumMappingStrategy
        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

        public javax.lang.model.element.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 interface EnumMappingStrategy
        Returns:
        the type element of the exception that should be used, never null
      • getUnexpectedValueMappingExceptionClass

        protected java.lang.Class<? extends java.lang.Exception> getUnexpectedValueMappingExceptionClass()