This method provides a way for the developer to provide information
about the arguments expected by this directive. The definition of
arguments would provide information to the framework about how each
argument should be parsed and interpretted.
This method uses
UsageDefinition#Builder to build the token
definitions. Each token definition consists of
name,
TokenTypeand
optional field that specifies whether the token specified is
optionally present.
The
UsageDefinition provides different methods to
define,
and as well generate
usage based on the definition.
This method is invoked by the framework at the time of creating an executable
directive that will be added to the
RecipePipeline. It's generally during
the configuration phase.
.
NOTE: As best practice, developer needs to make sure that this class doesn't
throw an exception. Also, it should not include external libraries that can
generate exception unknown to the developer.
Following is an example of how
define could be used.
public UsageDefinition define() {
UsageDefinition.Builder builder = UsageDefinition.builder();
builder.define("column", TokeType.COLUMN_NAME); // :column
builder.define("number", TokenType.NUMERIC, Optional.TRUE); // 1.0 or 8
builder.define("text", TokenType.TEXT); // 'text'
builder.define("boolean", TokenType.BOOL); // true / false
builder.define("expression", TokenType.EXPRESSOION); // exp: { age < 10.0 }
}
TokenType supports many different token types that can be used within the
usage definition.