2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.api;
10 import com.google.common.collect.ImmutableSet;
12 import javax.annotation.Nonnull;
15 * Interface describing YANG 'identity' statement.
18 * The 'identity' statement is used to define a new globally unique, abstract,
19 * and untyped identity. Its only purpose is to denote its name, semantics, and
20 * existence. The built-in datatype "identityref" can be used to reference
21 * identities within a data model.
23 public interface IdentitySchemaNode extends SchemaNode {
25 * Return the base identity.
26 * @deprecated use {@link #getBaseIdentities()} instead.
28 * @return an existing identity, from which the new identity is derived or
29 * null, if the identity is defined from scratch.
31 @Deprecated IdentitySchemaNode getBaseIdentity();
34 * The YANG 1.0 (RFC6020) implementation of IdentitySchemaNode always returns an ImmutableSet containing just one
35 * base identity or an empty ImmutableSet as it does not support multiple base identities.
36 * Starting with YANG 1.1 (RFC7950), the identity can be derived from multiple base identities.
38 * @return set of existing identities from which the new identity is derived or
39 * an empty ImmutableSet if the identity is defined from scratch.
41 // FIXME: version 2.0.0: make this method non-default
42 @Nonnull default Set<IdentitySchemaNode> getBaseIdentities() {
43 final IdentitySchemaNode base = getBaseIdentity();
44 return base == null ? ImmutableSet.of() : ImmutableSet.of(base);
48 * Get identities derived from this identity.
50 * @return collection of identities derived from this identity
52 Set<IdentitySchemaNode> getDerivedIdentities();