*/
package org.opendaylight.yangtools.yang.model.api;
-import com.google.common.collect.ImmutableSet;
-import java.util.Set;
-import javax.annotation.Nonnull;
+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
+ * 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.
- * </p>
*/
public interface IdentitySchemaNode extends SchemaNode {
-
/**
- * @deprecated use {@link #getBaseIdentities()} instead
+ * 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.
*
- * @return an existing identity, from which the new identity is derived or
- * null, if the identity is defined from scratch.
- */
- @Deprecated IdentitySchemaNode getBaseIdentity();
-
- /**
- * The YANG 1.0 (RFC6020) implementation of IdentitySchemaNode always returns an ImmutableSet containing just one
- * base identity or an empty ImmutableSet as it does not support multiple base identities.
- * Starting with YANG 1.1 (RFC7950), the identity can be derived from multiple 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 ImmutableSet if the identity is defined from scratch.
+ * @return set of existing identities from which the new identity is derived or an empty Set if the identity is
+ * a root identity.
*/
- // FIXME: version 2.0.0: make this method non-default
- @Nonnull default Set<IdentitySchemaNode> getBaseIdentities() {
- final IdentitySchemaNode base = getBaseIdentity();
- return base == null ? ImmutableSet.of() : ImmutableSet.of(base);
- }
+ @NonNull Collection<? extends IdentitySchemaNode> getBaseIdentities();
/**
* Get identities derived from this identity.
*
* @return collection of identities derived from this identity
*/
- Set<IdentitySchemaNode> getDerivedIdentities();
-
+ // 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();
}