Added support for identity statement.
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / IdentityrefType.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.util;
9
10 import java.util.Collections;
11 import java.util.List;
12
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
19
20 /**
21  * The <code>default</code> implementation of Identityref Type Definition
22  * interface.
23  *
24  * @see IdentityrefTypeDefinition
25  */
26 public final class IdentityrefType implements IdentityrefTypeDefinition {
27     private final QName name = BaseTypes.constructQName("identityref");
28     private final SchemaPath path;
29     private static final String DESCRIPTION = "The identityref type is used to reference an existing identity.";
30     private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.10";
31     private final IdentitySchemaNode identity;
32     private static final String UNITS = "";
33
34     public IdentityrefType(IdentitySchemaNode identity, SchemaPath schemaPath) {
35         this.identity = identity;
36         this.path = schemaPath;
37     }
38
39     @Override
40     public String getUnits() {
41         return UNITS;
42     }
43
44     @Override
45     public Object getDefaultValue() {
46         return identity;
47     }
48
49     @Override
50     public QName getQName() {
51         return name;
52     }
53
54     @Override
55     public SchemaPath getPath() {
56         return path;
57     }
58
59     @Override
60     public String getDescription() {
61         return DESCRIPTION;
62     }
63
64     @Override
65     public String getReference() {
66         return REFERENCE;
67     }
68
69     @Override
70     public Status getStatus() {
71         return Status.CURRENT;
72     }
73
74     @Override
75     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
76         return Collections.emptyList();
77     }
78
79     @Override
80     public IdentitySchemaNode getIdentity() {
81         return identity;
82     }
83
84     @Override
85     public IdentityrefTypeDefinition getBaseType() {
86         return null;
87     }
88
89     @Override
90     public String toString() {
91         return "identityref " + identity.getQName().getLocalName();
92     }
93
94 }