Package org.mapstruct

Enum NullValueCheckStrategy

java.lang.Object
java.lang.Enum<NullValueCheckStrategy>
org.mapstruct.NullValueCheckStrategy
All Implemented Interfaces:
Serializable, Comparable<NullValueCheckStrategy>, java.lang.constant.Constable

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.

Author:
Sean Huang
  • Enum Constant Details

    • ON_IMPLICIT_CONVERSION

      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.
    • ALWAYS

      public static final NullValueCheckStrategy ALWAYS
      This option always includes a null check.
  • Method Details

    • values

      public static NullValueCheckStrategy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      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.)
      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