Package org.mapstruct

Enum NullValuePropertyMappingStrategy

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      IGNORE
      If a source bean property equals null the target bean property will be ignored and retain its existing value.
      SET_TO_DEFAULT
      If a source bean property equals null the target bean property will be set to its default value.
      SET_TO_NULL
      If a source bean property equals null the target bean property will be set explicitly to null.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static NullValuePropertyMappingStrategy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static NullValuePropertyMappingStrategy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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.
    • Constructor Detail

      • NullValuePropertyMappingStrategy

        private NullValuePropertyMappingStrategy()
    • 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​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null