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

Inherit @Option annotation in subclasses #144

Open
ty1er opened this issue Jan 8, 2017 · 1 comment
Open

Inherit @Option annotation in subclasses #144

ty1er opened this issue Jan 8, 2017 · 1 comment

Comments

@ty1er
Copy link

ty1er commented Jan 8, 2017

I would really like to break my options in several classes and combine them to get the end configuration:

public interface Interface1 {
    @Option(name = "-param1", usage = "Paramter1") public void setParam1(String value);
}
public interface Interface2 {
    @Option(name = "-param2", usage = "Paramter2") public void setParam2(String value);
}
public class Config implements Interface1,Interface2 {
    public String param1;
    public String param2;
    public void setParam2(String value) {
        param2 = value;
    }
    public void setParam1(String value) {
        param1 = value;
    }

However the is no way of using Config and an args4j configuration because @option annotation is not inherited in subclasses.
Marking @option with @inherited will enable that feature

@haridaniel
Copy link

haridaniel commented Feb 7, 2017

I have the same issue. Option annotations are not working through inherited config classes. Concretely it results in strange errors like "... is not a valid option", but it listed in usage print.
I think this is because the code runs recursively up on class hierarchy searching for annotations, but somehow thats handled in a wrong way. Probably @inherited on @option annotation declaration could solve this but I am not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants