EndsWith Annotation

@EndsWith

The @EndsWith annotation can be used to require that values given end with a given suffix. For example:

 @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:

 @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.

If you have a prefixes you need to enforce then use the @StartsWith annotation. For more complex string value enforcement you can also use the regular expression based @Pattern annotation.


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.