Skip to content

Add annotations to Generated codeΒ #1574

@vadim-shb

Description

@vadim-shb

I just want to share an idea... I think it would be great to be able to add any annotations you want to generated classes/methods.
Something like this:

@Annotated({
  @Component,
  @Qualifier("fooMapper")
})
@Mapper
public interface FooMapper {
  @Annotated({
    @Cacheable(value = "cache", key = "mappedFoo #foo.id" )
  })
  Foo map(Foo foo);
}

So, the content of @Annotated would be added to generated code like this:

@Component,
@Qualifier("fooMapper")
public class FooMapperImpl implements FooMapper {
  @Cacheable(value = "cache", key = "mappedFoo #foo.id" )
  Foo map(Foo foo) {
  ...
  }
}

With this functionality we wouldn't need @Mapper(componentModel = "spring") for example, and many annotation-based issues would gone.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions