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.model.api.YangStmtMapping;
15 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
18 @Rfc6020AbnfRule("type-stmt")
19 public interface TypeStatement extends DeclaredStatement<String> {
21 default StatementDefinition statementDefinition() {
22 return YangStmtMapping.TYPE;
25 @Rfc6020AbnfRule("numerical-restrictions")
26 // FIXME: 7.0.0: this interface does not have an implementation
27 interface NumericalRestrictions extends TypeStatement {
28 default @Nullable RangeStatement getRange() {
29 return findFirstDeclaredSubstatement(RangeStatement.class).orElse(null);
33 @Rfc6020AbnfRule("decimal64-specification")
34 interface Decimal64Specification extends TypeStatement {
35 default @NonNull FractionDigitsStatement getFractionDigits() {
36 return findFirstDeclaredSubstatement(FractionDigitsStatement.class).get();
39 default @Nullable RangeStatement getRange() {
40 final Optional<RangeStatement> opt = findFirstDeclaredSubstatement(RangeStatement.class);
41 return opt.isPresent() ? opt.get() : null;
45 @Rfc6020AbnfRule("string-restrictions")
46 // FIXME: 7.0.0: this interface does not have an implementation
47 interface StringRestrictions extends TypeStatement {
48 default @Nullable LengthStatement getLength() {
49 final Optional<LengthStatement> opt = findFirstDeclaredSubstatement(LengthStatement.class);
50 return opt.isPresent() ? opt.get() : null;
53 default @NonNull Collection<? extends PatternStatement> getPatterns() {
54 return declaredSubstatements(PatternStatement.class);
58 @Rfc6020AbnfRule("enum-specification")
59 interface EnumSpecification extends TypeStatement {
61 default @NonNull Collection<? extends EnumStatement> getEnums() {
62 return declaredSubstatements(EnumStatement.class);
66 @Rfc6020AbnfRule("leafref-specification")
67 interface LeafrefSpecification extends TypeStatement {
68 default @NonNull PathStatement getPath() {
69 return findFirstDeclaredSubstatement(PathStatement.class).get();
73 * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
76 * @return require-instance statement, if present.
78 default @Nullable RequireInstanceStatement getRequireInstance() {
79 final Optional<RequireInstanceStatement> opt =
80 findFirstDeclaredSubstatement(RequireInstanceStatement.class);
81 return opt.isPresent() ? opt.get() : null;
85 @Rfc6020AbnfRule("instanceidentifier-specification")
86 interface InstanceIdentifierSpecification extends TypeStatement {
88 * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
91 * @return require-instance statement, if present.
93 default @Nullable RequireInstanceStatement getRequireInstance() {
94 final Optional<RequireInstanceStatement> opt =
95 findFirstDeclaredSubstatement(RequireInstanceStatement.class);
96 return opt.isPresent() ? opt.get() : null;
100 @Rfc6020AbnfRule("identityref-specification")
101 interface IdentityRefSpecification extends TypeStatement {
103 * Returns the base statements.
105 * @return collection of base statements (in YANG 1.1 models) or a collection containing just one base
106 * statement (in YANG 1.0 models)
108 default @NonNull Collection<? extends BaseStatement> getBases() {
109 return declaredSubstatements(BaseStatement.class);
113 @Rfc6020AbnfRule("bits-specification")
114 interface BitsSpecification extends TypeStatement {
115 default @NonNull Collection<? extends BitStatement> getBits() {
116 return declaredSubstatements(BitStatement.class);
120 @Rfc6020AbnfRule("union-specification")
121 interface UnionSpecification extends TypeStatement {
122 default @NonNull Collection<? extends TypeStatement> getTypes() {
123 return declaredSubstatements(TypeStatement.class);
127 @Rfc6020AbnfRule("binary-specification")
128 interface BinarySpecification extends TypeStatement {
129 default @NonNull Collection<? extends LengthStatement> getLength() {
130 return declaredSubstatements(LengthStatement.class);