@Target(value={FIELD,METHOD,ANNOTATION_TYPE}) @Retention(value=CLASS) public @interface 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.
|
boolean |
reverseConvertGenerate
是否生成反向转换的逻辑。
该属性只针对复杂转换,且 MapStruct 默认不会自动转换的属性生效,比如多层结构:a.b 转换为当前类的 c
|
String |
source
来源,默认取当前字段名称
- 可以是当前类中的属性名
- 也可以是属性名.属性名,例如:address.city.name
|
String |
target |
Class<?> |
targetClass |
public abstract Class<?> targetClass
public abstract boolean reverseConvertGenerate
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.