Package org.mapstruct

Annotation Type Named

  • @Target({TYPE,METHOD})
    public @interface Named
    Marks mapping methods with the given qualifier name. Can be used to qualify a single method or all methods of a given type by specifying this annotation on the type level.

    Will be used to select the correct mapping methods when mapping a bean property type, element of an iterable type or the key/value of a map type.

    Example (both methods of Titles are capable to convert a string, but the ambiguity is resolved by applying the qualifiers in @Mapping:

     public class Titles {
       public String translateTitleEG(String title) {
           // some mapping logic
       public String translateTitleGE(String title) {
           // some mapping logic
     @Mapper( uses = Titles.class )
     public interface MovieMapper {
        @Mapping( target = "title", qualifiedByName = { "TitleTranslator", "EnglishToGerman" } )
        GermanRelease toGerman( OriginalRelease movies );
    The following implementation of MovieMapper will be generated:
     public class MovieMapperImpl implements MovieMapper {
         private final Titles titles = new Titles();
         public GermanRelease toGerman(OriginalRelease movies) {
             if ( movies == null ) {
                 return null;
             GermanRelease germanRelease = new GermanRelease();
             germanRelease.setTitle( titles.translateTitleEG( movies.getTitle() ) );
             return germanRelease;
    Sjaak Derksen
    See Also:
    Mapping.qualifiedByName(), IterableMapping.qualifiedByName(), MapMapping.keyQualifiedByName(), MapMapping.valueQualifiedByName()
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String value
      A name qualifying the annotated element
    • Element Detail

      • value

        String value
        A name qualifying the annotated element
        the name.