Propagate @NonNull collection annotations
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / DocumentedNode.java
index 36acbe9b5168c770bbff5558bf1d736b065bafea..6fe4a293bcec65de4ee059d7d92cd998a355a27d 100644 (file)
@@ -7,38 +7,45 @@
  */
 package org.opendaylight.yangtools.yang.model.api;
 
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
+
 /**
- *
  * Node which can have documentation assigned.
- *
  */
 public interface DocumentedNode {
-
     /**
-     * Returns description of the instance of the type <code>SchemaNode</code>
+     * Returns the value of the argument of YANG <code>description</code> keyword.
      *
-     * @return string with textual description the node which represents the
-     *         argument of the YANG <code>description</code> substatement
+     * @return string with the description, or empty if description was not provided.
      */
-    String getDescription();
+    Optional<String> getDescription();
 
     /**
-     * Returns reference of the instance of the type <code>SchemaNode</code>
-     *
-     * The reference refers to external document that provides additional
-     * information relevant for the instance of this type.
+     * Returns the value of the argument of YANG <code>reference</code> keyword.
      *
-     * @return string with the reference to some external document which
-     *         represents the argument of the YANG <code>reference</code>
-     *         substatement
+     * @return string with reference to some other document, or empty if reference was not provided.
      */
-    String getReference();
+    Optional<String> getReference();
 
     /**
-     * Returns status of the instance of the type <code>SchemaNode</code>
+     * Returns unknown schema nodes which belongs to this instance. Default implementation returns an empty collection.
      *
-     * @return status of this node which represents the argument of the YANG
-     *         <code>status</code> substatement
+     * @return collection of unknown schema nodes defined under this node.
      */
-    Status getStatus();
+    default @NonNull Collection<? extends @NonNull UnknownSchemaNode> getUnknownSchemaNodes() {
+        return ImmutableList.of();
+    }
+
+    interface WithStatus extends DocumentedNode {
+        /**
+         * Returns status of the instance of the type <code>SchemaNode</code>.
+         *
+         * @return status of this node which represents the argument of the YANG
+         *         <code>status</code> substatement
+         */
+        @NonNull Status getStatus();
+    }
 }