Package org.mapstruct

Enum NullValuePropertyMappingStrategy

    • Enum Constant Detail

      • SET_TO_NULL

        public static final NullValuePropertyMappingStrategy SET_TO_NULL
        If a source bean property equals null the target bean property will be set explicitly to null.
      • SET_TO_DEFAULT

        public static final NullValuePropertyMappingStrategy SET_TO_DEFAULT
        If a source bean property equals null the target bean property will be set to its default value.

        This means:

        1. For List MapStruct generates an ArrayList
        2. For Map a HashMap
        3. For arrays an empty array
        4. For String ""
        5. for primitive / boxed types a representation of 0 or false
        6. For all other objects an new instance is created, requiring an empty constructor.

        Make sure that a Mapping.defaultValue() is defined if no empty constructor is available on the default value.

      • IGNORE

        public static final NullValuePropertyMappingStrategy IGNORE
        If a source bean property equals null the target bean property will be ignored and retain its existing value.
    • Method Detail

      • values

        public static NullValuePropertyMappingStrategy[] 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 (NullValuePropertyMappingStrategy c : NullValuePropertyMappingStrategy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static NullValuePropertyMappingStrategy 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.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null