Refactor augment statement implementation
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / IdentitySchemaNode.java
index 597b7a8acbf3b9d8fa1efee313bac77fc5c19db0..686be4a9f81a1f403797b9a73b77e79973929149 100644 (file)
@@ -1,36 +1,44 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.model.api;\r
-\r
-import java.util.Set;\r
-\r
-/**\r
- * Interface describing YANG 'identity' statement.\r
- * <p>\r
- * The 'identity' statement is used to define a new globally unique, abstract,\r
- * and untyped identity. Its only purpose is to denote its name, semantics, and\r
- * existence. The built-in datatype "identityref" can be used to reference\r
- * identities within a data model.\r
- * </p>\r
- */\r
-public interface IdentitySchemaNode extends SchemaNode {\r
-\r
-    /**\r
-     * @return an existing identity, from which the new identity is derived or\r
-     *         null, if the identity is defined from scratch.\r
-     */\r
-    IdentitySchemaNode getBaseIdentity();\r
-\r
-    /**\r
-     * Get identities derived from this identity.\r
-     *\r
-     * @return collection of identities derived from this identity\r
-     */\r
-    Set<IdentitySchemaNode> getDerivedIdentities();\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api;
+
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * Interface describing YANG 'identity' statement.
+ *
+ * <p>
+ * The 'identity' statement is used to define a new globally unique, abstract, and untyped identity. Its only purpose
+ * is to denote its name, semantics, and existence. The built-in datatype "identityref" can be used to reference
+ * identities within a data model.
+ */
+public interface IdentitySchemaNode extends SchemaNode {
+    /**
+     * Return base identities of this identity. The semantics of differ between RFC6020 and RFC7950 here. YANG 1.0
+     * uses single inheritance, where there can be 0..1 base identities. YANG 1.1 uses multiple inheritance, where
+     * there can be 0..N base identities.
+     *
+     * <p>
+     * Callers should be prepared to handle multiple base identities.
+     *
+     * @return set of existing identities from which the new identity is derived or an empty Set if the identity is
+     *         a root identity.
+     */
+    @NonNull Collection<? extends IdentitySchemaNode> getBaseIdentities();
+
+    /**
+     * Get identities derived from this identity.
+     *
+     * @return collection of identities derived from this identity
+     */
+    // FIXME: 5.0.0: this causes circular references in implementation objects under immutables+builder pattern,
+    //               and really should be a SchemaContext-level utility (i.e. walk entire SchemaContext, cache the
+    //               result)
+    @NonNull Collection<? extends IdentitySchemaNode> getDerivedIdentities();
+}