2 * Copyright (c) 2015 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.parser.stmt.rfc6020.effective.type;
10 import java.util.Collections;
11 import java.util.List;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.common.YangConstants;
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.TypeDefinition;
18 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
22 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.IdentityRefSpecification;
23 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
24 import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
25 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.TypeUtils;
28 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
29 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BaseEffectiveStatementImpl;
30 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase;
32 public class IdentityRefSpecificationEffectiveStatementImpl extends
33 EffectiveStatementBase<String, IdentityRefSpecification> implements IdentityrefTypeDefinition,
34 TypeEffectiveStatement<IdentityRefSpecification> {
36 private static final QName QNAME = QName.create(YangConstants.RFC6020_YANG_MODULE, TypeUtils.IDENTITY_REF);
38 private static final String DESCRIPTION = "The identityref type is used to reference an existing identity.";
39 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.10";
41 private static final String UNITS = "";
43 private final SchemaPath path;
45 private final IdentitySchemaNode identity;
46 private IdentityrefType identityRefTypeInstance = null;
48 public IdentityRefSpecificationEffectiveStatementImpl(
49 final StmtContext<String, IdentityRefSpecification, EffectiveStatement<String, IdentityRefSpecification>> ctx) {
52 path = Utils.getSchemaPath(ctx.getParentContext()).createChild(QNAME);
54 final BaseEffectiveStatementImpl base = firstEffective(BaseEffectiveStatementImpl.class);
56 QName identityQName = base.argument();
57 StmtContext<?, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> identityCtx = ctx.getFromNamespace(IdentityNamespace.class, identityQName);
58 identity = (IdentitySchemaNode) identityCtx.buildEffective();
65 public IdentitySchemaNode getIdentity() {
70 public IdentityrefTypeDefinition getBaseType() {
75 public String getUnits() {
80 public Object getDefaultValue() {
85 public QName getQName() {
90 public SchemaPath getPath() {
95 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
96 return Collections.emptyList();
100 public String getDescription() {
105 public String getReference() {
110 public Status getStatus() {
111 return Status.CURRENT;
115 public String toString() {
116 return "identityref " + identity.getQName().getLocalName();
120 public TypeDefinition<?> getTypeDefinition() {
122 if (identityRefTypeInstance != null) {
123 return identityRefTypeInstance;
126 identityRefTypeInstance = IdentityrefType.create(path, identity);
128 return identityRefTypeInstance;