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.
- @file and @Directory - @startsWith and @ENDSWITH
- Loading branch information
Showing
5 changed files
with
80 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
layout: page | ||
title: EndsWith Annotation | ||
--- | ||
|
||
## `@EndsWith` | ||
|
||
The `@EndsWith` annotation can be used to require that values given end with a given suffix. For example: | ||
|
||
```java | ||
@Option(name = "--images") | ||
@EndsWith(suffixes = { ".jpg", ".png", ".gif" }) | ||
public List<String> images = new ArrayList<>(); | ||
``` | ||
|
||
Here the `--images` option requires that any image given ends with one of the file extensions `.jpg`, `.png` or `.gif` | ||
|
||
### Case Sensitivity | ||
|
||
Optionally you can make the prefixes case insensitive by setting the `ignoreCase` field to `true` and also specifying a `locale` if needed: | ||
|
||
```java | ||
@Option(name = "--images") | ||
@EndsWith(ignoreCase = true, locale = "en", suffixes = { ".jpg", ".png", ".gif" }) | ||
public List<String> images = new ArrayList<>(); | ||
``` | ||
|
||
When declared like this the suffixes and any values given for the option will first be lower cased in the given locale before being compared. | ||
|
||
### Related Annotations | ||
|
||
If you have a prefixes you need to enforce then use the [`@StartsWith`](starts-with.html) annotation. For more complex string value enforcement you can also use the regular expression based [`@Pattern`](pattern.html) annotation. |
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: StartsWith Annotation | ||
--- | ||
|
||
## `@StartsWith` | ||
|
||
The `@StartsWith` annotation can be used to require that values given start with a given prefix. For example: | ||
|
||
```java | ||
@Option(name = "--urls") | ||
@StartsWith(prefixes = { "http", "https", "ftp" }) | ||
public List<String> urls = new ArrayList<>(); | ||
``` | ||
Here the `--urls` option requires that any URL given starts with one of `http`, `https` or `ftp` | ||
|
||
### Case Sensitivity | ||
|
||
Optionally you can make the prefixes case insensitive by setting the `ignoreCase` field to `true` and also specifying a `locale` if needed: | ||
|
||
```java | ||
@Option(name = "--urls") | ||
@StartsWith(ignoreCase = true, locale = "en", prefixes = { "http", "https", "ftp" }) | ||
public List<String> urls = new ArrayList<>(); | ||
``` | ||
|
||
When declared like this the prefixes and any values given for the option will first be lower cased in the given locale before being compared. | ||
|
||
### Related Annotations | ||
|
||
If you have a suffixes you need to enforce then use the [`@EndsWith`](ends-with.html) annotation. For more complex string value enforcement you can also use the regular expression based [`@Pattern`](pattern.html) annotation. |