All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cdap.wrangler.api.parser.TokenDefinition Maven / Gradle / Ivy

There is a newer version: 4.10.1
Show newest version
/*
 * Copyright © 2017-2019 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package io.cdap.wrangler.api.parser;

import io.cdap.wrangler.api.annotations.PublicEvolving;

import java.io.Serializable;

/**
 * The TokenDefinition class represents a definition of token as specified
 * by the user while defining a directive usage. All definitions of a token are represented
 * by a instance of this class.
 *
 * The definition are constant (immutable) and they cannot be changed once defined.
 * For example :
 * 
 *   TokenDefinition token = new TokenDefintion("column", TokenType.COLUMN_NAME, null, 0, Optional.FALSE);
 * 
 *
 * 

The class TokenDefinition includes methods for retrieveing different members of * like name of the token, type of the token, label associated with token, whether it's optional or not * and the ordinal number of the token in the TokenGroup.

* *

As this class is immutable, the constructor requires all the member variables to be presnted * for an instance of this object to be created.

*/ @PublicEvolving public final class TokenDefinition implements Serializable { private final int ordinal; private final boolean optional; private final String name; private final TokenType type; private final String label; public TokenDefinition(String name, TokenType type, String label, int ordinal, boolean optional) { this.name = name; this.type = type; this.label = label; this.ordinal = ordinal; this.optional = optional; } /** * @return Label associated with the token. Label provides a way to override the usage description * for this TokenDefinition. If a label is not provided, then this return null. */ public String label() { return label; } /** * @return Returns the oridinal number of this TokenDefinition within * the TokenGroup, */ public int ordinal() { return ordinal; } /** * @return true, if this TokenDefinition is optional, false otherwise. */ public boolean optional() { return optional; } /** * @return Name of this TokenDefinition */ public String name() { return name; } /** * @return Returns the type of this TokenDefinition. */ public TokenType type() { return type; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy