2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.api.stmt;
10 import java.util.Collection;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
16 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
17 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
19 @Rfc6020AbnfRule("type-stmt")
20 public interface TypeStatement extends DeclaredStatement<QName> {
22 default StatementDefinition statementDefinition() {
23 return YangStmtMapping.TYPE;
26 @Rfc6020AbnfRule("numerical-restrictions")
27 // FIXME: 7.0.0: this interface does not have an implementation
28 interface NumericalRestrictions extends TypeStatement {
29 default @Nullable RangeStatement getRange() {
30 return findFirstDeclaredSubstatement(RangeStatement.class).orElse(null);
34 @Rfc6020AbnfRule("decimal64-specification")
35 interface Decimal64Specification extends TypeStatement {
36 default @NonNull FractionDigitsStatement getFractionDigits() {
37 return findFirstDeclaredSubstatement(FractionDigitsStatement.class).get();
40 default @Nullable RangeStatement getRange() {
41 final Optional<RangeStatement> opt = findFirstDeclaredSubstatement(RangeStatement.class);
42 return opt.isPresent() ? opt.get() : null;
46 @Rfc6020AbnfRule("string-restrictions")
47 // FIXME: 7.0.0: this interface does not have an implementation
48 interface StringRestrictions extends TypeStatement {
49 default @Nullable LengthStatement getLength() {
50 final Optional<LengthStatement> opt = findFirstDeclaredSubstatement(LengthStatement.class);
51 return opt.isPresent() ? opt.get() : null;
54 default @NonNull Collection<? extends PatternStatement> getPatterns() {
55 return declaredSubstatements(PatternStatement.class);
59 @Rfc6020AbnfRule("enum-specification")
60 interface EnumSpecification extends TypeStatement {
62 default @NonNull Collection<? extends EnumStatement> getEnums() {
63 return declaredSubstatements(EnumStatement.class);
67 @Rfc6020AbnfRule("leafref-specification")
68 interface LeafrefSpecification extends TypeStatement {
69 default @NonNull PathStatement getPath() {
70 return findFirstDeclaredSubstatement(PathStatement.class).get();
74 * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
77 * @return require-instance statement, if present.
79 default @Nullable RequireInstanceStatement getRequireInstance() {
80 final Optional<RequireInstanceStatement> opt =
81 findFirstDeclaredSubstatement(RequireInstanceStatement.class);
82 return opt.isPresent() ? opt.get() : null;
86 @Rfc6020AbnfRule("instanceidentifier-specification")
87 interface InstanceIdentifierSpecification extends TypeStatement {
89 * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
92 * @return require-instance statement, if present.
94 default @Nullable RequireInstanceStatement getRequireInstance() {
95 final Optional<RequireInstanceStatement> opt =
96 findFirstDeclaredSubstatement(RequireInstanceStatement.class);
97 return opt.isPresent() ? opt.get() : null;
101 @Rfc6020AbnfRule("identityref-specification")
102 interface IdentityRefSpecification extends TypeStatement {
104 * Returns the base statements.
106 * @return collection of base statements (in YANG 1.1 models) or a collection containing just one base
107 * statement (in YANG 1.0 models)
109 default @NonNull Collection<? extends BaseStatement> getBases() {
110 return declaredSubstatements(BaseStatement.class);
114 @Rfc6020AbnfRule("bits-specification")
115 interface BitsSpecification extends TypeStatement {
116 default @NonNull Collection<? extends BitStatement> getBits() {
117 return declaredSubstatements(BitStatement.class);
121 @Rfc6020AbnfRule("union-specification")
122 interface UnionSpecification extends TypeStatement {
123 default @NonNull Collection<? extends TypeStatement> getTypes() {
124 return declaredSubstatements(TypeStatement.class);
128 @Rfc6020AbnfRule("binary-specification")
129 interface BinarySpecification extends TypeStatement {
130 default @NonNull Collection<? extends LengthStatement> getLength() {
131 return declaredSubstatements(LengthStatement.class);