Package io.micronaut.context.annotation
Annotation Interface Mapper
@Retention(RUNTIME)
@Target({METHOD,TYPE})
@Executable(processOnStartup=true)
public @interface Mapper
An annotation that can be used on abstract methods for mapping, merging multiple objects.
The method needs to define a single return type and at least one argument.
Inspired by similar frameworks like MapStruct but internally uses the BeanIntrospection
model.
- Since:
- 4.1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The conflict strategy specifies the behaviour if a conflict is found.static @interface
The mappings.static interface
An interface for defining merge strategies. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe merge strategy to use if method has more than one parameter. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
A merge strategy to supply tomergeStrategy()
.static final String
A merge strategy to supply tomergeStrategy()
.
-
Field Details
-
MERGE_STRATEGY_ALWAYS_OVERRIDE
A merge strategy to supply tomergeStrategy()
. Properties from subsequent arguments will always override properties from previous arguments with the same name.- See Also:
-
MERGE_STRATEGY_NOT_NULL_OVERRIDE
A merge strategy to supply tomergeStrategy()
. Non-null properties from subsequent arguments will override properties from previous arguments.- See Also:
-
-
Element Details
-
value
Mapper.Mapping[] value- Returns:
- Defined mappings.
- Default:
- {}
-
conflictStrategy
Mapper.ConflictStrategy conflictStrategy- Returns:
- The conflict strategy.
- Default:
- CONVERT
-
mergeStrategy
String mergeStrategyThe merge strategy to use if method has more than one parameter.By default, any non-null property from subsequent arguments will override property with the same name from previous arguments.
To define a custom strategy, create a named singleton of type
Mapper.MergeStrategy
and specify the same name here.- Returns:
- The merge strategy
- Default:
- "NOT_NULL_OVERRIDE"
-