org.mapstruct.ValueMappings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mapstruct Show documentation
Show all versions of mapstruct Show documentation
An annotation processor for generating type-safe bean mappers
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 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
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface ValueMappings {
ValueMapping[] value();
}