Package org.mapstruct
Enum NullValueMappingStrategy
- All Implemented Interfaces:
Serializable,Comparable<NullValueMappingStrategy>,java.lang.constant.Constable
Strategy for dealing with
null values passed to mapping methods.- Author:
- Sjaak Derksen
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIfnullis passed to a mapping method, a default value will be returned.Ifnullis passed to a mapping method,nullwill be returned, unless the return type isOptional, in which case an empty optional will be returned. -
Method Summary
Modifier and TypeMethodDescriptionstatic NullValueMappingStrategyReturns 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 Details
-
RETURN_NULL
Ifnullis passed to a mapping method,nullwill be returned, unless the return type isOptional, in which case an empty optional will be returned. That's the default behavior if no alternative strategy is configured globally, for given mapper or method. -
RETURN_DEFAULT
Ifnullis 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 withnullvalues in this case. - For iterable mapping methods an empty collection will be returned.
- For map mapping methods an empty map will be returned.
- For optional mapping methods an empty optional 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 Details
-
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
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
-