Eliminate IdentityStatement.getBase()
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / TypeStatement.java
1 /*
2  * Copyright (c) 2015 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.stmt;
9
10 import java.util.Collection;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
14
15 @Rfc6020AbnfRule("type-stmt")
16 public interface TypeStatement extends DeclaredStatement<String> {
17
18     @Nonnull String getName();
19
20     @Rfc6020AbnfRule("numerical-restrictions")
21     interface NumericalRestrictions extends TypeStatement {
22
23         @Nonnull RangeStatement getRange();
24     }
25
26     @Rfc6020AbnfRule("decimal64-specification")
27     interface Decimal64Specification extends TypeStatement {
28
29         @Nonnull FractionDigitsStatement getFractionDigits();
30
31         @Nullable RangeStatement getRange();
32     }
33
34     @Rfc6020AbnfRule("string-restrictions")
35     interface StringRestrictions extends TypeStatement {
36
37         @Nullable LengthStatement getLength();
38
39         @Nonnull Collection<? extends PatternStatement> getPatterns();
40     }
41
42     @Rfc6020AbnfRule("enum-specification")
43     interface EnumSpecification extends TypeStatement {
44
45         @Nonnull Collection<? extends EnumStatement> getEnums();
46     }
47
48     @Rfc6020AbnfRule("leafref-specification")
49     interface LeafrefSpecification extends TypeStatement {
50
51         @Nonnull PathStatement getPath();
52
53         /**
54          * All implementations should override this method.
55          * The default definition of this method is used only in YANG 1.0 (RFC6020) implementation of
56          * LeafrefSpecification which does not support require-instance statement.
57          * YANG leafref type has been changed in YANG 1.1 (RFC7950) and now allows require-instance statement.
58          *
59          * @return require-instance statement
60          */
61          // FIXME: version 2.0.0: make this method non-default
62         @Nullable default RequireInstanceStatement getRequireInstance() {
63             return null;
64         }
65     }
66
67     @Rfc6020AbnfRule("instanceidentifier-specification")
68     interface InstanceIdentifierSpecification extends TypeStatement {
69
70         @Nullable RequireInstanceStatement getRequireInstance();
71     }
72
73     @Rfc6020AbnfRule("identityref-specification")
74     interface IdentityRefSpecification extends TypeStatement {
75         /**
76          * Returns the base statements.
77          *
78          * @return collection of base statements (in YANG 1.1 models) or a collection containing just one base
79          *         statement (in YANG 1.0 models)
80          */
81         @Nonnull Collection<? extends BaseStatement> getBases();
82     }
83
84     @Rfc6020AbnfRule("bits-specification")
85     interface BitsSpecification extends TypeStatement {
86
87         @Nonnull Collection<? extends BitStatement> getBits();
88     }
89
90     @Rfc6020AbnfRule("union-specification")
91     interface UnionSpecification extends TypeStatement {
92
93         @Nonnull Collection<? extends TypeStatement> getTypes();
94     }
95
96     @Rfc6020AbnfRule("binary-specification")
97     interface BinarySpecification extends TypeStatement {
98
99         @Nullable LengthStatement getLength();
100     }
101 }