Package org.mapstruct
Annotation Type ValueMappings
Constructs a set of value (constant) mappings.
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(target = "M", source = "MALE"),
@ValueMapping(target = "F", source = "FEMALE")
})
GenderDto mapToDto(Gender gender);
}
//Java 8 and later
@Mapper
public interface GenderMapper {
@ValueMapping(target = "M", source = "MALE"),
@ValueMapping(target = "F", source = "FEMALE")
GenderDto mapToDto(Gender gender);
}
- Author:
- Sjaak Derksen
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionThe value mappings that should be applied.
-
Element Details
-
value
ValueMapping[] valueThe value mappings that should be applied.- Returns:
- the value mappings
-