Package org.mapstruct

Enum NullValueCheckStrategy

  • All Implemented Interfaces:
    Serializable, Comparable<NullValueCheckStrategy>

    public enum NullValueCheckStrategy
    extends Enum<NullValueCheckStrategy>
    Strategy for dealing with null source values. Note: This strategy is not in effect when a specific source presence check method is defined in the service provider interface (SPI).

    Note: some types of mappings (collections, maps), in which MapStruct is instructed to use a getter or adder as target accessor see CollectionMappingStrategy, MapStruct will always generate a source property null check, regardless the value of the NullValueCheckStrategy to avoid addition of null to the target collection or map.

    Sean Huang
    • Enum Constant Detail


        public static final NullValueCheckStrategy ON_IMPLICIT_CONVERSION
        This option includes a null check. When:

        1. a source value is directly assigned to a target
        2. a source value assigned to a target by calling a type conversion on the target first

        NOTE: mapping methods (generated or hand written) are excluded from this null check. They are intended to handle a null source value as 'valid' input.
    • Method Detail

      • values

        public static NullValueCheckStrategy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (NullValueCheckStrategy c : NullValueCheckStrategy.values())
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static NullValueCheckStrategy valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        name - the name of the enum constant to be returned.
        the enum constant with the specified name
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null