Enum CollectionMappingStrategy
- All Implemented Interfaces:
Serializable,Comparable<CollectionMappingStrategy>,java.lang.constant.Constable
In the table below, the dash - indicates a property name.
Next, the trailing s indicates the plural form.
The table explains the options and how they are applied to the presence / absence of a
set-s, add- and / or get-s method on the target object.
| Option | Only target set-s Available | Only target add- Available | Both set-s/add- Available | No set-s/add- Available | Existing Target (@TargetType) |
|---|---|---|---|---|---|
ACCESSOR_ONLY |
set-s | get-s | set-s | get-s | get-s |
SETTER_PREFERRED |
set-s | add- | set-s | get-s | get-s |
ADDER_PREFERRED |
set-s | add- | add- | get-s | get-s |
TARGET_IMMUTABLE |
set-s | exception | set-s | exception | set-s |
- 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 ConstantDescriptionThe setter of the target property will be used to propagate the value:orderDto.setOrderLines(order.getOrderLines).Identical toSETTER_PREFERRED, only that adder methods will be preferred over setter methods, if both are present for a given collection-typed property.If present, the setter of the target property will be used to propagate the value:orderDto.setOrderLines(order.getOrderLines).Identical toSETTER_PREFERRED, however the target collection will not be cleared and accessed via addAll in case of updating existing bean instances, see:MappingTarget. -
Method Summary
Modifier and TypeMethodDescriptionstatic CollectionMappingStrategyReturns the enum constant of this type with the specified name.static CollectionMappingStrategy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ACCESSOR_ONLY
The setter of the target property will be used to propagate the value:orderDto.setOrderLines(order.getOrderLines).If no setter is available but a getter method, this will be used, under the assumption it has been initialized:
orderDto.getOrderLines().addAll(order.getOrderLines). This will also be the case when usingMappingTarget(updating existing instances). -
SETTER_PREFERRED
If present, the setter of the target property will be used to propagate the value:orderDto.setOrderLines(order.getOrderLines).If no setter but and adder method is present, that adder will be invoked for each element of the source collection:
order.addOrderLine(orderLine() ).If neither a setter nor an adder method but a getter for the target property is present, that getter will be used, assuming it returns an initialized collection: If no setter is available, MapStruct will first look for an adder method before resorting to a getter.
-
ADDER_PREFERRED
Identical toSETTER_PREFERRED, only that adder methods will be preferred over setter methods, if both are present for a given collection-typed property. -
TARGET_IMMUTABLE
Identical toSETTER_PREFERRED, however the target collection will not be cleared and accessed via addAll in case of updating existing bean instances, see:MappingTarget. Instead the target accessor (e.g. set) will be used on the target bean to set the collection.
-
-
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
-