MutuallyExclusiveWith Annotation

@MutuallyExclusiveWith

The @MutuallyExclusiveWith annotation is applied to a field annotated with @Option to indicate that exactly one from some set of options may be specified e.g.

@Option(name = "--num", 
        arity = 1, 
        title = "Number")
@MutuallyExclusiveWith(tag = "identifier")
private int number;

@Option(name = "--name",
        arity = 1,
        title = "Name")
@MutuallyExclusiveWith(tag = "identifier")
private String name;

When fields are marked with @MutuallyExclusiveWith if the user specifies more than one of the options that have the same tag value then an error will be thrown during parsing.

In this example the user may specify exactly one of the --num or --name option or they may specify neither. If they specify both then it is treated as an error.

If you want to require that at least one of some set of options be specified then you should use @RequireSome instead.

If you want to require exactly one from some set of options then you should use @RequireOnlyOne.


Improving this Documentation

This documentation is itself open source and lives in GitHub under the docs/ directory.

I am not a professional technical writer and as the developer of this software I can often make assumptions of knowledge that you as a user reading this may not have. Improvements to the documentation are always welcome, if you have suggestions for the documentation please submit pull requests to the main branch.