Skip to content

Annotated default-returning methods #667

@Citymonstret

Description

@Citymonstret

Allow @DefaultValue to apply to methods, in which case the method will produce a default value. Flexible signatures can be supported with the new annotated method system.

This would be merged after #598.

@DefaultValue("name")
public @NonNull ArgumentParseResult<YourValue> defaultValue(
  final @NonNull CommandContext<YourSenderType> context
) {
  // logic...
  return theValue;
}

then in the method, @DefaultValue(provider = "name")

We'd have to make the value of @DefaultValue default to "", which should be fine. We need a small class for housing the name-provider mappings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions