Eliminate IdentityStatement.getBase()
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / TypeStatement.java
index a89d1da5345ec4644fc93c4b8e83a2c993ac1499..d11b04f629ee02d03455cc6ba9df4f1bbd8a6979 100644 (file)
@@ -10,11 +10,10 @@ package org.opendaylight.yangtools.yang.model.api.stmt;
 import java.util.Collection;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
 @Rfc6020AbnfRule("type-stmt")
-public interface TypeStatement extends DeclaredStatement<QName> {
+public interface TypeStatement extends DeclaredStatement<String> {
 
     @Nonnull String getName();
 
@@ -22,7 +21,6 @@ public interface TypeStatement extends DeclaredStatement<QName> {
     interface NumericalRestrictions extends TypeStatement {
 
         @Nonnull RangeStatement getRange();
-
     }
 
     @Rfc6020AbnfRule("decimal64-specification")
@@ -31,7 +29,6 @@ public interface TypeStatement extends DeclaredStatement<QName> {
         @Nonnull FractionDigitsStatement getFractionDigits();
 
         @Nullable RangeStatement getRange();
-
     }
 
     @Rfc6020AbnfRule("string-restrictions")
@@ -46,34 +43,59 @@ public interface TypeStatement extends DeclaredStatement<QName> {
     interface EnumSpecification extends TypeStatement {
 
         @Nonnull Collection<? extends EnumStatement> getEnums();
-
     }
 
     @Rfc6020AbnfRule("leafref-specification")
     interface LeafrefSpecification extends TypeStatement {
 
-        @Nullable PathStatement getPath();
-
+        @Nonnull PathStatement getPath();
+
+        /**
+         * All implementations should override this method.
+         * The default definition of this method is used only in YANG 1.0 (RFC6020) implementation of
+         * LeafrefSpecification which does not support require-instance statement.
+         * YANG leafref type has been changed in YANG 1.1 (RFC7950) and now allows require-instance statement.
+         *
+         * @return require-instance statement
+         */
+         // FIXME: version 2.0.0: make this method non-default
+        @Nullable default RequireInstanceStatement getRequireInstance() {
+            return null;
+        }
     }
 
+    @Rfc6020AbnfRule("instanceidentifier-specification")
     interface InstanceIdentifierSpecification extends TypeStatement {
 
         @Nullable RequireInstanceStatement getRequireInstance();
     }
 
-
+    @Rfc6020AbnfRule("identityref-specification")
     interface IdentityRefSpecification extends TypeStatement {
-
+        /**
+         * Returns the base statements.
+         *
+         * @return collection of base statements (in YANG 1.1 models) or a collection containing just one base
+         *         statement (in YANG 1.0 models)
+         */
+        @Nonnull Collection<? extends BaseStatement> getBases();
     }
+
+    @Rfc6020AbnfRule("bits-specification")
     interface BitsSpecification extends TypeStatement {
 
         @Nonnull Collection<? extends BitStatement> getBits();
-
     }
 
+    @Rfc6020AbnfRule("union-specification")
     interface UnionSpecification extends TypeStatement {
 
         @Nonnull Collection<? extends TypeStatement> getTypes();
+    }
 
+    @Rfc6020AbnfRule("binary-specification")
+    interface BinarySpecification extends TypeStatement {
+
+        @Nullable LengthStatement getLength();
     }
 }