Package org.mapstruct
Enum NullValueMappingStrategy
- java.lang.Object
-
- java.lang.Enum<NullValueMappingStrategy>
-
- org.mapstruct.NullValueMappingStrategy
-
- All Implemented Interfaces:
Serializable
,Comparable<NullValueMappingStrategy>
public enum NullValueMappingStrategy extends Enum<NullValueMappingStrategy>
Strategy for dealing withnull
values passed to mapping methods.- Author:
- Sjaak Derksen
-
-
Enum Constant Summary
Enum Constants Enum Constant Description RETURN_DEFAULT
Ifnull
is passed to a mapping method, a default value will be returned.RETURN_NULL
Ifnull
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(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.
-
-
-
Enum Constant Detail
-
RETURN_NULL
public static final NullValueMappingStrategy RETURN_NULL
Ifnull
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
Ifnull
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()
orMapping.constant()
will be populated based on the given expression or constant. Note that expressions must be prepared to deal withnull
values in this case. - For iterable mapping methods an empty collection will be returned.
- For map mapping methods an empty map will be returned.
- For bean mapping methods the target type will be instantiated and returned. Any properties of the target type
which are mapped via
-
-
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(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 nameNullPointerException
- if the argument is null
-
-