Skip to content

Annotations are automatically passed in forged methods #3015

Description

@chenzijia12300

Currently the @AnnotateWith annotation modification on the original method is automatically passed to its forgeMethod method, should we change it to an optional one, regarding whether it is automatically passed to its derived method

e.g. currently for

@Mapper
public interface AnnotationForgeMapper {

    @AnnotateWith( CustomMethodOnlyAnnotation.class )
    List<Target> map(List<Source> sources);

}

will generate

public class AnnotationForgeMapperImpl implements AnnotationForgeMapper {

    @CustomMethodOnlyAnnotation
    @Override
    public List<Target> map(List<Source> sources) {
        if ( sources == null ) {
            return null;
        }

        List<Target> list = new ArrayList<Target>( sources.size() );
        for ( Source source : sources ) {
            list.add( sourceToTarget( source ) );
        }

        return list;
    }

    @CustomMethodOnlyAnnotation

    protected Target sourceToTarget(Source source) {
        if ( source == null ) {
            return null;
        }

        Target target = new Target();

        target.setValue( source.getValue() );

        return target;
    }
}

We can see that the sourceToTarget method also carries the CustomMethodOnlyAnnotation annotation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions