forked from airlift/airline
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation for some restriction annotations (#35)
- Document various requirement annotations - Links for occurrences annotations - Partially document @unrestricted annotation
- Loading branch information
Showing
10 changed files
with
136 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
layout: page | ||
title: MutuallyExclusiveWith Annotation | ||
--- | ||
|
||
## `@MutuallyExclusiveWith` | ||
|
||
The `@MutuallyExclusiveWith` annotation is applied to a field annotated with [`@Option`](option.html) to indicate that exactly one from some set of options may be specified e.g. | ||
|
||
```java | ||
@Option(name = "--num", | ||
arity = 1, | ||
title = "Number") | ||
@MutuallyExclusiveWith(tag = "identifier") | ||
private int number; | ||
|
||
@Option(name = "--name", | ||
arity = 1, | ||
title = "Name") | ||
@MutuallyExclusiveWith(tag = "identifier") | ||
``` | ||
|
||
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](../parser/). | ||
|
||
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. | ||
|
||
### Related Annotations | ||
|
||
If you want to require that at least one of some set of options be specified then you should use [`@RequireSome`](require-some.html) instead. | ||
|
||
If you want to require exactly one from some set of options then you should use [`@RequireOnlyOne`](require-only-one.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
layout: page | ||
title: RequireOnlyOne Annotation | ||
--- | ||
|
||
## `@RequireOnlyOne` | ||
|
||
The `@RequireOnlyOne` annotation is applied to a field annotated with [`@Option`](option.html) to indicate that exactly one from some set of options must be specified e.g. | ||
|
||
```java | ||
@Option(name = "--num", | ||
arity = 1, | ||
title = "Number") | ||
@RequireOnlyOne(tag = "identifier") | ||
private int number; | ||
|
||
@Option(name = "--name", | ||
arity = 1, | ||
title = "Name") | ||
@RequireOnlyOne(tag = "identifier") | ||
``` | ||
|
||
When fields are marked with `@RequireOnlyOne` if the user fails to supply exactly one of the options that have the same `tag` value then an error will be thrown during [parsing](../parser/). | ||
|
||
In this example the user must specify exactly one of the `--num` or `--name` option, if they specify neither or specify both then it is treated as an error. | ||
|
||
### Related Annotations | ||
|
||
If you want to require that at least one of some set of options be specified then you should use [`@RequireSome`](require-some.html) instead. | ||
|
||
If you optionally want to allow only one from some set of options then you should use [`@MutuallyExclusiveWith`](mutually-exclusive-with.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
layout: page | ||
title: RequireSome Annotation | ||
--- | ||
|
||
## `@RequireSome` | ||
|
||
The `@RequireSome` annotation is applied to a field annotated with [`@Option`](option.html) to indicate that at least one from some set of options must be specified e.g. | ||
|
||
```java | ||
@Option(name = "--num", | ||
arity = 1, | ||
title = "Number") | ||
@RequireSome(tag = "identifier") | ||
private int number; | ||
|
||
@Option(name = "--name", | ||
arity = 1, | ||
title = "Name") | ||
@RequireSome(tag = "identifier") | ||
``` | ||
|
||
When fields are marked with `@RequireSome` if the user fails to supply at least one of the options that have the same `tag` value then an error will be thrown during [parsing](../parser/). | ||
|
||
In this example the user must specify at least one of the `--num` or `--name` option and may specify both if desired. | ||
|
||
### Related Annotations | ||
|
||
If you want to require that at most one of some set of options be specified then you should use [`@RequireOnlyOne`](require-only-one.html) instead. | ||
|
||
If you optionally want to allow only one from some set of options then you should use [`@MutuallyExclusiveWith`](mutually-exclusive-with.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
layout: page | ||
title: Unrestricted Annotation | ||
--- | ||
|
||
## `@Unrestricted` | ||
|
||
The `@Unrestricted` annotation is applied to fields annotated with [`@Option`](option.html) or [`@Arguments`](arguments.html) to indicate that no restrictions should apply. | ||
|
||
This is useful because by default restrictions are inherited so if you wish to remove restrictions when overriding an option definition then you need to use this annotation. | ||
|