Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain annotations of my interface like @NotNull in generated classes. #122

Open
Snowbae1017 opened this issue Nov 23, 2022 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@Snowbae1017
Copy link

Snowbae1017 commented Nov 23, 2022

Hi, when using autopipeline, I encountered a little difficulty about using annotation.

The annotations in my interface like @NotNull cannot be retained in the generated classes (including the implementations of my interface and the Handler interface), which makes it impossible for me to constrain the Handler implementations at the interface level.
code sample:

@AutoPipeline
public interface ConfigSource {
    @NotNull
    String get(@NotNull String key);
}

// I hope the implementations of ConfigSourceHandler can also be constrained by @NotNull.
public class ConfigSourceHandlerImpl implements ConfigSourceHandler {
    @Override
    public String get(String key, ConfigSourceHandlerContext configSourceHandlerContext) {
        return null;
    }
}
@oldratlee oldratlee added the enhancement New feature or request label Nov 24, 2022
@oldratlee
Copy link
Member

oldratlee commented Nov 24, 2022

reasonable nice-to-have feature ❤️

@zavakid zavakid self-assigned this Nov 26, 2022
@zavakid
Copy link
Member

zavakid commented Nov 29, 2022

In my opinion, the issue actually suggests AutoPipeline to take the annotations from the interface ( which may present on the interface, method, or parameter) to the generated classes, I think there are some corner cases we need to think about.

e.g. obviously, we need to ignore the @AutoPipeline / @PipelineDirection , and also, we need to ignore the @FunctionalInterface because class have the @FunctionalInterface annotation will cause some compile error, and so is the @SuppressWarnings annotations...

We can't find out all the cases that we need to ignore, we can't exhaust all bad cases.

Maybe we need to add some configuration to let user specify which annotation will take to the pipeline class, but it will increase the complexity of the library.

and, from another perspective, we need to ensure the correct of the generated classes, and we indeed need a solution to the @NotNull / @NonNull case.

So, I think the solution is to add another annotation to specify which annotation will be used in the generated classes,
it may increase some complexity, and we need to try to keep simple to the users as far as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants