Class ProtobufEnumMappingStrategy

  • All Implemented Interfaces:
    org.mapstruct.ap.spi.EnumMappingStrategy

    public class ProtobufEnumMappingStrategy
    extends org.mapstruct.ap.spi.DefaultEnumMappingStrategy
    • Field Detail

      • DEFAULT_ENUM_CONSTANT

        protected static final String DEFAULT_ENUM_CONSTANT
    • Constructor Detail

      • ProtobufEnumMappingStrategy

        public ProtobufEnumMappingStrategy()
    • Method Detail

      • getDefaultEnumConstant

        protected static String getDefaultEnumConstant()
        The enum constant postfix used as default value in protobuf, ie for enum "Cake" the default constant should be CAKE_UNSPECIFIED = 0; This is the recommended style according to Googles style guide https://developers.google.com/protocol-buffers/docs/style#enums . If you use some other pattern in your protobuf files you can simply subclass this class and override this method.
      • isMapEnumConstantToNull

        public boolean isMapEnumConstantToNull​(TypeElement enumType,
                                               String sourceEnumValue)
      • getDefaultNullEnumConstant

        public String getDefaultNullEnumConstant​(TypeElement enumType)
        Specified by:
        getDefaultNullEnumConstant in interface org.mapstruct.ap.spi.EnumMappingStrategy
        Overrides:
        getDefaultNullEnumConstant in class org.mapstruct.ap.spi.DefaultEnumMappingStrategy
      • getEnumConstant

        public String getEnumConstant​(TypeElement enumType,
                                      String sourceEnumValue)
        Specified by:
        getEnumConstant in interface org.mapstruct.ap.spi.EnumMappingStrategy
        Overrides:
        getEnumConstant in class org.mapstruct.ap.spi.DefaultEnumMappingStrategy