public final class UsageDefinition extends Object implements Serializable
UsageDefinition provides a way for users to registers the argument for UDDs.
UsageDefinition is a collection of TokenDefinition and the name of the directive
itself. Each token specification has an associated ordinal that can be used to position the argument
within the directive.
Following is a example of how this class can be used.
UsageDefinition.Builder builder = UsageDefinition.builder();
builder.add("col1", TypeToken.COLUMN_NAME); // By default, this field is required.
builder.add("col2", TypeToken.COLUMN_NAME, false); // This is a optional field.
builder.add("expression", TypeToken.EXPRESSION);
UsageDefinition definition = builder.build();
NOTE: No constraints checks are included in this implementation.TokenDefinition,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
UsageDefinition.Builder
This inner builder class provides a way to create
UsageDefinition
object. |
| Modifier and Type | Method and Description |
|---|---|
static UsageDefinition.Builder |
builder(String directive)
This is a static method for creating a builder for the
UsageDefinition
object. |
String |
getDirectiveName()
Returns the name of the directive for which the this
UsageDefinition
object is created. |
int |
getOptionalTokensCount()
Returns the count of
TokenDefinition that have been specified
as optional in the UsageDefinition. |
List<TokenDefinition> |
getTokens()
This method returns the list of
TokenDefinition that should be
used for parsing the directive into Arguments. |
String |
toString()
This method converts the
UsageDefinition into a usage string
for this directive. |
public String getDirectiveName()
UsageDefinition
object is created.public List<TokenDefinition> getTokens()
TokenDefinition that should be
used for parsing the directive into Arguments.TokenDefinition.public int getOptionalTokensCount()
TokenDefinition that have been specified
as optional in the UsageDefinition.public String toString()
UsageDefinition into a usage string
for this directive. It inspects all the tokens to generate a standard syntax
for the usage of the directive.public static UsageDefinition.Builder builder(String directive)
UsageDefinition
object. In order to create a UsageDefinition, a builder has to created.
This builder is provided as user API for constructing the usage specification for a directive.
directive - name of the directive for which the builder is created for.UsageDefinition.Builder object that can be used to construct
UsageDefinition object.Copyright © 2023 CDAP Licensed under the Apache License, Version 2.0.