@Target(value={FIELD,METHOD,ANNOTATION_TYPE}) @Retention(value=CLASS) public @interface ReverseAutoMapping
AutoMapper 的生成规则是由配置注解的当前类,生成与目标类之间的转换接口,所以其内部字段中的 AutoMapping 都是基于该条件来配置的。
虽然默认情况下会生成目标类到当前类的转换,但如果自定义配置的话,仍需要到目标类上面进行配置。
但现实情况中,可能会出现目标类,不能或者不建议增加配置注解,所以,这里提供一种在一种类上面自定义配置两个类转换的方式。 如果需要配置由目标类转换为配置注解的当前类具体转换逻辑的话,可以使用当前注解
需要注意的是,如果在当前类中配置了该注解信息,则在目标类中不能够再定义与该类转换相关的注解,例如AutoMapper、AutoMapping
| Modifier and Type | Optional Element and Description |
|---|---|
String |
conditionExpression |
String[] |
conditionQualifiedByName
String-based form of qualifiers for condition / presence check methods;
When looking for a suitable presence check method for a given property, MapStruct will
only consider those methods carrying directly or indirectly (i.e.
|
String |
constant |
String |
dateFormat |
String |
defaultExpression |
String |
defaultValue
默认值
|
String[] |
dependsOn
One or more properties of the result type on which the mapped property depends.
|
String |
expression |
boolean |
ignore |
Class<? extends Annotation> |
mappingControl
Allows detailed control over the mapping process.
|
org.mapstruct.NullValueCheckStrategy |
nullValueCheckStrategy
Determines when to include a null check on the source property value of a bean mapping.
|
org.mapstruct.NullValuePropertyMappingStrategy |
nullValuePropertyMappingStrategy
The strategy to be applied when the source property is
null or not present. |
String |
numberFormat |
Class<? extends Annotation>[] |
qualifiedBy
A qualifier can be specified to aid the selection process of a suitable mapper.
|
String[] |
qualifiedByName
String-based form of qualifiers; When looking for a suitable mapping method for a given property, MapStruct will
only consider those methods carrying directly or indirectly (i.e.
|
String |
source
来源,默认取当前字段名称
- 可以是当前类中的属性名
- 也可以是属性名.属性名,例如:address.city.name
|
String |
target |
Class<?> |
targetClass |
public abstract Class<?> targetClass
public abstract String source
public abstract String target
public abstract String dateFormat
public abstract String numberFormat
public abstract String constant
public abstract String expression
public abstract String defaultExpression
public abstract String conditionExpression
public abstract String defaultValue
public abstract Class<? extends Annotation>[] qualifiedBy
Note that defaultValue() usage will also be converted using this qualifier.
qualifier 可以置顶限定符来帮助选择合适的转换方法。qualifier 是一个自定义的注解,可以标注在 mapper 类或者方法上。
Note that defaultValue() usage will also be converted using this qualifier.
Qualifierpublic abstract String[] qualifiedByName
Named annotation
for each of the specified qualifier names.
Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large number of qualifiers as no custom annotation types are needed.
Note that defaultValue() usage will also be converted using this qualifier.
Namedpublic abstract String[] conditionQualifiedByName
Named annotation
for each of the specified qualifier names.
This is similar like qualifiedByName() but it is only applied for Condition methods.
Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large number of qualifiers as no custom annotation types are needed.
qualifiedByName(),
Namedpublic abstract String[] dependsOn
An error will be raised in case a cycle in the dependency relationships is detected.
public abstract org.mapstruct.NullValueCheckStrategy nullValueCheckStrategy
MapperConfig, Mapper or BeanMapping.public abstract org.mapstruct.NullValuePropertyMappingStrategy nullValuePropertyMappingStrategy
null or not present. If no strategy is configured,
the strategy given via MapperConfig.nullValuePropertyMappingStrategy(),
BeanMapping.nullValuePropertyMappingStrategy() or
Mapper.nullValuePropertyMappingStrategy() will be applied.
NullValuePropertyMappingStrategy.SET_TO_NULL will be used by default.null is passed as source property value or the source property
is not present.public abstract Class<? extends Annotation> mappingControl
DeepClone,
NoComplexMapping,
MappingControlCopyright © 2025. All rights reserved.