Package org.mapstruct

Enum NullValueMappingStrategy

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

    public enum NullValueMappingStrategy
    extends java.lang.Enum<NullValueMappingStrategy>
    Strategy for dealing with null values passed to mapping methods.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      RETURN_DEFAULT
      If null is passed to a mapping method, a default value will be returned.
      RETURN_NULL
      If null is passed to a mapping method, null will be returned.
    • Method Summary

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

      • RETURN_NULL

        public static final NullValueMappingStrategy RETURN_NULL
        If null is passed to a mapping method, null will be returned. That's the default behavior if no alternative strategy is configured globally, for given mapper or method.
      • RETURN_DEFAULT

        public static final NullValueMappingStrategy RETURN_DEFAULT
        If null is passed to a mapping method, a default value will be returned. The value depends on the kind of the annotated method:
        • For bean mapping methods the target type will be instantiated and returned. Any properties of the target type which are mapped via Mapping.expression() or Mapping.constant() will be populated based on the given expression or constant. Note that expressions must be prepared to deal with null values in this case.
        • For iterable mapping methods an empty collection will be returned.
        • For map mapping methods an empty map will be returned.
    • Constructor Detail

      • NullValueMappingStrategy

        private NullValueMappingStrategy()
    • Method Detail

      • values

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

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