Cleanup checkstyle in yang-{data,model}-api
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / IdentitySchemaNode.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.api;
9
10 import com.google.common.collect.ImmutableSet;
11 import java.util.Set;
12 import javax.annotation.Nonnull;
13
14 /**
15  * Interface describing YANG 'identity' statement.
16  *
17  * <p>
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.
22  */
23 public interface IdentitySchemaNode extends SchemaNode {
24     /**
25      * Return the base identity.
26      * @deprecated use {@link #getBaseIdentities()} instead.
27      *
28      * @return an existing identity, from which the new identity is derived or
29      *         null, if the identity is defined from scratch.
30      */
31     @Deprecated IdentitySchemaNode getBaseIdentity();
32
33     /**
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.
37      *
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.
40      */
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);
45     }
46
47     /**
48      * Get identities derived from this identity.
49      *
50      * @return collection of identities derived from this identity
51      */
52     Set<IdentitySchemaNode> getDerivedIdentities();
53
54 }