Package redempt.ordinate.context
Interface ContextProvider<T,V>
- Type Parameters:
T
- The sender typeV
- The type being provided
- All Superinterfaces:
Named
Extracts values from a command's execution context so they can be passed as arguments to the final dispatcher
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
V> ContextProvider<T, V> create
(String name, String error, Function<CommandContext<T>, V> provider) Creates a context providergetError()
provide
(CommandContext<T> context) Provides the context value for the given command execution context
-
Method Details
-
create
static <T,V> ContextProvider<T,V> create(String name, String error, Function<CommandContext<T>, V> provider) Creates a context provider- Type Parameters:
T
- The sender typeV
- The type being provided- Parameters:
name
- The name of the providererror
- The error to be shown if the provider returns nullprovider
- The function to provide the value- Returns:
- A context provider
-
provide
Provides the context value for the given command execution context- Parameters:
context
- The command execution context- Returns:
- The generated context value
-
getError
String getError()- Returns:
- The error to be displayed if the context cannot be generated
-