Package org.mapstruct

Annotation Type Ignored


Configures the ignored of one bean attribute.

The name all attributes of for ignored is to be specified via targets().

Example 1: Implicitly mapping fields with the same name:


 // We need ignored Human.name and Human.lastName
 // we can use @Ignored with parameters "name", "lastName" targets()
 @Mapper
 public interface HumanMapper {
    @Ignored( targets = { "name", "lastName" } )
    HumanDto toHumanDto(Human human)
 }
 

 // generates:
 @Override
 public HumanDto toHumanDto(Human human) {
    humanDto.setFullName( human.getFullName() );
    // ...
 }
 
Author:
Ivashin Aleksey
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Whether the specified properties should be ignored by the generated mapping method.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The prefix that should be applied to all the properties specified via targets().
  • Element Details

    • targets

      String[] targets
      Whether the specified properties should be ignored by the generated mapping method. This can be useful when certain attributes should not be propagated from source to target or when properties in the target object are populated using a decorator and thus would be reported as unmapped target property by default.
      Returns:
      The target names of the configured properties that should be ignored
    • prefix

      String prefix
      The prefix that should be applied to all the properties specified via targets().
      Returns:
      The target prefix to be applied to the defined properties
      Default:
      ""