Rename {Data,Schema}TreeAwareEffectiveStatement.Namespace
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / TypeDefinition.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.api;
9
10 import java.util.Optional;
11
12 /**
13  * YANG statement <code>typedef</code> contains also substatements
14  * <ul>
15  * <li><code>default</code> - default value which is compatible with
16  * <code>type</code>,</li>
17  * <li><code>type</code> - base type from which is <code>typedef</code> derived,
18  * </li>
19  * <li><code>units</code> - textual information about units associated with this
20  * type.</li>
21  * </ul>
22  * This interface contains the methods for getting the values of the arguments of substatements mentioned above.
23  * Furthermore {@link LeafSchemaNode} and {@link LeafListSchemaNode} interfaces contribute to their internal type
24  * definitions.
25  *
26  * @param <T>
27  *            type of the base type (YANG <code>type</code> substatement) which
28  *            is included in the instance of this type
29  */
30 // FIXME: 8.0.0: it seems this construct is mostly used in yang-data-api/codec view of the world. Introduce a dead
31 //               ringer interface at that layer, which will not have a SchemaNode implication but (perhaps) is backed
32 //               by a TypedefEffectiveStatement (or TypeEffectiveStatement?)
33 public interface TypeDefinition<T extends TypeDefinition<?>> extends SchemaNode {
34     /**
35      * Returns the base type from which this type is derived. If this is yang built-in type, returns null.
36      *
37      * @return value of <code>&lt;T&gt;</code> type which represents the base
38      *         type of instance of the <code>TypeDefinition</code> type or null,
39      *         if this is yang built-in type
40      */
41     T getBaseType();
42
43     /**
44      * Returns the unit which represents the value of the argument of the <code>units</code> substatement of the YANG
45      * <code>typedef</code>, <code>leaf</code> or <code>leaf-list</code> statements.
46      *
47      * @return string with units in which is type measured
48      */
49     Optional<String> getUnits();
50
51     /**
52      * Returns the default value which represents the value of the argument of the <code>default</code> substatement
53      * of the YANG <code>typedef</code> or <code>leaf</code> statement.
54      *
55      * @return instance of <code>Object</code> type which contains default value for <code>typedef</code>
56      */
57     Optional<? extends Object> getDefaultValue();
58 }