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 static com.google.common.base.Verify.verifyNotNull;
12 import java.util.Collection;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
20 @Rfc6020AbnfRule("type-stmt")
21 public interface TypeStatement extends DeclaredStatement<String> {
23 default StatementDefinition statementDefinition() {
24 return YangStmtMapping.TYPE;
27 default @NonNull String getName() {
28 // FIXME: YANGTOOLS-908: verifyNotNull() should not be needed here
29 return verifyNotNull(argument());
32 @Rfc6020AbnfRule("numerical-restrictions")
33 // FIXME: 6.0.0: this interface does not have an implementation
34 interface NumericalRestrictions extends TypeStatement {
35 // FIXME: 6.0.0: this is not accurate, 'range' is an optional statement
36 default @NonNull RangeStatement getRange() {
37 return findFirstDeclaredSubstatement(RangeStatement.class).get();
41 @Rfc6020AbnfRule("decimal64-specification")
42 interface Decimal64Specification extends TypeStatement {
43 default @NonNull FractionDigitsStatement getFractionDigits() {
44 return findFirstDeclaredSubstatement(FractionDigitsStatement.class).get();
47 default @Nullable RangeStatement getRange() {
48 final Optional<RangeStatement> opt = findFirstDeclaredSubstatement(RangeStatement.class);
49 return opt.isPresent() ? opt.get() : null;
53 @Rfc6020AbnfRule("string-restrictions")
54 // FIXME: 6.0.0: this interface does not have an implementation
55 interface StringRestrictions extends TypeStatement {
56 default @Nullable LengthStatement getLength() {
57 final Optional<LengthStatement> opt = findFirstDeclaredSubstatement(LengthStatement.class);
58 return opt.isPresent() ? opt.get() : null;
61 default @NonNull Collection<? extends PatternStatement> getPatterns() {
62 return declaredSubstatements(PatternStatement.class);
66 @Rfc6020AbnfRule("enum-specification")
67 interface EnumSpecification extends TypeStatement {
69 default @NonNull Collection<? extends EnumStatement> getEnums() {
70 return declaredSubstatements(EnumStatement.class);
74 @Rfc6020AbnfRule("leafref-specification")
75 interface LeafrefSpecification extends TypeStatement {
76 default @NonNull PathStatement getPath() {
77 return findFirstDeclaredSubstatement(PathStatement.class).get();
81 * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
84 * @return require-instance statement, if present.
86 default @Nullable RequireInstanceStatement getRequireInstance() {
87 final Optional<RequireInstanceStatement> opt =
88 findFirstDeclaredSubstatement(RequireInstanceStatement.class);
89 return opt.isPresent() ? opt.get() : null;
93 @Rfc6020AbnfRule("instanceidentifier-specification")
94 interface InstanceIdentifierSpecification extends TypeStatement {
96 * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
99 * @return require-instance statement, if present.
101 default @Nullable RequireInstanceStatement getRequireInstance() {
102 final Optional<RequireInstanceStatement> opt =
103 findFirstDeclaredSubstatement(RequireInstanceStatement.class);
104 return opt.isPresent() ? opt.get() : null;
108 @Rfc6020AbnfRule("identityref-specification")
109 interface IdentityRefSpecification extends TypeStatement {
111 * Returns the base statements.
113 * @return collection of base statements (in YANG 1.1 models) or a collection containing just one base
114 * statement (in YANG 1.0 models)
116 default @NonNull Collection<? extends BaseStatement> getBases() {
117 return declaredSubstatements(BaseStatement.class);
121 @Rfc6020AbnfRule("bits-specification")
122 interface BitsSpecification extends TypeStatement {
123 default @NonNull Collection<? extends BitStatement> getBits() {
124 return declaredSubstatements(BitStatement.class);
128 @Rfc6020AbnfRule("union-specification")
129 interface UnionSpecification extends TypeStatement {
130 default @NonNull Collection<? extends TypeStatement> getTypes() {
131 return declaredSubstatements(TypeStatement.class);
135 @Rfc6020AbnfRule("binary-specification")
136 interface BinarySpecification extends TypeStatement {
137 default @NonNull Collection<? extends LengthStatement> getLength() {
138 return declaredSubstatements(LengthStatement.class);