All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mapstruct.MappingTarget Maven / Gradle / Ivy

There is a newer version: 1.6.3
Show newest version
/*
 * 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;

/**
 * Declares a parameter of a mapping method to be the target of the mapping.
 * 

* Not more than one parameter can be declared as {@code MappingTarget}. *

* NOTE: The parameter passed as a mapping target must not be {@code null}. * *

* Example 1: Update exist bean without return value *

*

 * @Mapper
 * public interface HumanMapper {
 *     void updateHuman(HumanDto humanDto, @MappingTarget Human human);
 * }
 * 
*

 * // generates
 * @Override
 * public void updateHuman(HumanDto humanDto, Human human) {
 *     human.setName( humanDto.getName() );
 *     // ...
 * }
 * 
*

* Example 2: Update exist bean and return it *

*

 * @Mapper
 * public interface HumanMapper {
 *     Human updateHuman(HumanDto humanDto, @MappingTarget Human human);
 * }
 * 
* // generates: *

 * @Override
 * public Human updateHuman(HumanDto humanDto, Human human) {
 *     // ...
 *     human.setName( humanDto.getName() );
 *     return human;
 * }
 *
* * * @author Andreas Gudian */ @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.CLASS) public @interface MappingTarget { }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy