@Target(value=METHOD) @Retention(value=CLASS) public @interface ValueMappings
TIP: When using Java 8 or later, you can omit the @ValueMappings wrapper annotation and directly specify several @ValueMapping annotations on one method.
These two examples are equal
// before Java 8
@Mapper
public interface GenderMapper {
@ValueMappings({
@ValueMapping(source = "MALE", target = "M"),
@ValueMapping(source = "FEMALE", target = "F")
})
GenderDto mapToDto(Gender gender);
}
//Java 8 and later
@Mapper
public interface GenderMapper {
@ValueMapping(source = "MALE", target = "M"),
@ValueMapping(source = "FEMALE", target = "F")
GenderDto mapToDto(Gender gender);
}
Modifier and Type | Required Element and Description |
---|---|
ValueMapping[] |
value |
public abstract ValueMapping[] value
Copyright © 2012-2021 MapStruct Authors; All rights reserved. Released under the Apache Software License 2.0.