Remove Rfc6020AbnfRule
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / TypeStatement.java
index c7e7ecc3c4eb958ee0cce9f23965f0f8b549e660..6f05dc5a1b77b7dc3a9afa6365f5c3687667d3cc 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.api.stmt;
 
 import java.util.Collection;
-import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -19,14 +18,12 @@ import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 /**
  * Declared representation of a {@code type} statement.
  */
-@Rfc6020AbnfRule("type-stmt")
 public interface TypeStatement extends DeclaredStatement<QName> {
     @Override
     default StatementDefinition statementDefinition() {
         return YangStmtMapping.TYPE;
     }
 
-    @Rfc6020AbnfRule("numerical-restrictions")
     // FIXME: 7.0.0: this interface does not have an implementation
     interface NumericalRestrictions extends TypeStatement {
         default @Nullable RangeStatement getRange() {
@@ -34,24 +31,22 @@ public interface TypeStatement extends DeclaredStatement<QName> {
         }
     }
 
-    @Rfc6020AbnfRule("decimal64-specification")
     interface Decimal64Specification extends TypeStatement {
         default @NonNull FractionDigitsStatement getFractionDigits() {
-            return findFirstDeclaredSubstatement(FractionDigitsStatement.class).get();
+            return findFirstDeclaredSubstatement(FractionDigitsStatement.class).orElseThrow();
         }
 
         default @Nullable RangeStatement getRange() {
-            final Optional<RangeStatement> opt = findFirstDeclaredSubstatement(RangeStatement.class);
-            return opt.isPresent() ? opt.get() : null;
+            final var opt = findFirstDeclaredSubstatement(RangeStatement.class);
+            return opt.isPresent() ? opt.orElseThrow() : null;
         }
     }
 
-    @Rfc6020AbnfRule("string-restrictions")
     // FIXME: 7.0.0: this interface does not have an implementation
     interface StringRestrictions extends TypeStatement {
         default @Nullable LengthStatement getLength() {
-            final Optional<LengthStatement> opt = findFirstDeclaredSubstatement(LengthStatement.class);
-            return opt.isPresent() ? opt.get() : null;
+            final var opt = findFirstDeclaredSubstatement(LengthStatement.class);
+            return opt.isPresent() ? opt.orElseThrow() : null;
         }
 
         default @NonNull Collection<? extends PatternStatement> getPatterns() {
@@ -59,34 +54,28 @@ public interface TypeStatement extends DeclaredStatement<QName> {
         }
     }
 
-    @Rfc6020AbnfRule("enum-specification")
     interface EnumSpecification extends TypeStatement {
-
         default @NonNull Collection<? extends EnumStatement> getEnums() {
             return declaredSubstatements(EnumStatement.class);
         }
     }
 
-    @Rfc6020AbnfRule("leafref-specification")
     interface LeafrefSpecification extends TypeStatement {
         default @NonNull PathStatement getPath() {
-            return findFirstDeclaredSubstatement(PathStatement.class).get();
+            return findFirstDeclaredSubstatement(PathStatement.class).orElseThrow();
         }
 
         /**
-         * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
-         * null.
+         * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns null.
          *
          * @return require-instance statement, if present.
          */
         default @Nullable RequireInstanceStatement getRequireInstance() {
-            final Optional<RequireInstanceStatement> opt =
-                    findFirstDeclaredSubstatement(RequireInstanceStatement.class);
-            return opt.isPresent() ? opt.get() : null;
+            final var opt = findFirstDeclaredSubstatement(RequireInstanceStatement.class);
+            return opt.isPresent() ? opt.orElseThrow() : null;
         }
     }
 
-    @Rfc6020AbnfRule("instanceidentifier-specification")
     interface InstanceIdentifierSpecification extends TypeStatement {
         /**
          * Return require-instance statement child, if present. For RFC6020 semantics, this method always returns
@@ -95,13 +84,11 @@ public interface TypeStatement extends DeclaredStatement<QName> {
          * @return require-instance statement, if present.
          */
         default @Nullable RequireInstanceStatement getRequireInstance() {
-            final Optional<RequireInstanceStatement> opt =
-                    findFirstDeclaredSubstatement(RequireInstanceStatement.class);
-            return opt.isPresent() ? opt.get() : null;
+            final var opt = findFirstDeclaredSubstatement(RequireInstanceStatement.class);
+            return opt.isPresent() ? opt.orElseThrow() : null;
         }
     }
 
-    @Rfc6020AbnfRule("identityref-specification")
     interface IdentityRefSpecification extends TypeStatement {
         /**
          * Returns the base statements.
@@ -114,21 +101,18 @@ public interface TypeStatement extends DeclaredStatement<QName> {
         }
     }
 
-    @Rfc6020AbnfRule("bits-specification")
     interface BitsSpecification extends TypeStatement {
         default @NonNull Collection<? extends BitStatement> getBits() {
             return declaredSubstatements(BitStatement.class);
         }
     }
 
-    @Rfc6020AbnfRule("union-specification")
     interface UnionSpecification extends TypeStatement {
         default @NonNull Collection<? extends TypeStatement> getTypes() {
             return declaredSubstatements(TypeStatement.class);
         }
     }
 
-    @Rfc6020AbnfRule("binary-specification")
     interface BinarySpecification extends TypeStatement {
         default @NonNull Collection<? extends LengthStatement> getLength() {
             return declaredSubstatements(LengthStatement.class);