Package org.mapstruct

Enum NullValueCheckStrategy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<NullValueCheckStrategy>

    public enum NullValueCheckStrategy
    extends java.lang.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.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ALWAYS
      This option always includes a null check.
      ON_IMPLICIT_CONVERSION
      This option includes a null check.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static NullValueCheckStrategy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static NullValueCheckStrategy[] 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

      • 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.
    • Constructor Detail

      • NullValueCheckStrategy

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

        public static NullValueCheckStrategy 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