Annotation Type Default


@Retention(RUNTIME) @Target({PARAMETER,METHOD}) @API(status=STABLE) public @interface Default
When used on a method parameter:
Used to give an optional Argument a DefaultValue.

If value() is used then a parsed default value will be created. If name() is used then a dynamic default value registered to the DefaultValueRegistry will be used.


When used on a method:
Used to indicate that a method is a DefaultValueFactory. The method must return a DefaultValue instance. The only accepted method parameter is a Parameter which represents the parameter that the default value is being created for.
  • Element Details

    • value

      Returns the default value. name() will take priority when non-empty and used on a parameter.

      This value will be parsed when the command is being parsed in the case that the optional parameter has been omitted.

      Returns:
      the default value
      Default:
      ""
    • name

      If used on a parameter this returns the name of the DefaultValueFactory used to create the default value.

      If used on a method, this indicates the name of the DefaultValueFactory represented by the method. If this is empty, the method name will be used.

      The factories must be registered to the DefaultValueRegistry retrieved through AnnotationParser.defaultValueRegistry(). Using AnnotationParser.parse(Object[]) will scan & register all @Default-annotated methods.

      Returns:
      name of the default value registry to use
      Default:
      ""