Annotation Interface Suggestions


@Retention(RUNTIME) @Target({METHOD,TYPE_USE}) public @interface Suggestions
Special annotation available for use on methods returning String (including Optional<String>) values.

The presence of this annotation generates a union type of string and enum, where the values provided by value() will be the enum items. This makes it possible to create suggested/recommended values while still leaving the option to provide a custom one.

Example:

 
 @Suggestions({"red", "blue", "yellow"}) String getColor();
 
 

The above example would generate a configuration union type where the colors "red", "blue" and "yellow" are suggested options, but one could still provide a custom value like "magenta".

Note that, when used with Optional<String>, the annotation should be added on the String type as in the following example:

 
 Optional<@Suggestions({"red", "blue", "yellow"}) String> getColor();
 
 
Since:
3.0.0
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    An array of suggested values.
  • Element Details

    • value

      String[] value
      An array of suggested values.
      Returns:
      The suggested values