@StartsWith
The @StartsWith
annotation can be used to require that values given start with a given prefix. For example:
@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
Optionally you can make the prefixes case insensitive by setting the ignoreCase
field to true
and also specifying a locale
if needed:
@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.
If you have a suffixes you need to enforce then use the @EndsWith
annotation. For more complex string value enforcement you can also use the regular expression based @Pattern
annotation.
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.