3e330101b998828598c64b6934df00ce9d069318
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / thirdparty / plugin / ThirdPartyExtensionEffectiveStatementImpl.java
1 /*
2  * Copyright (c) 2016 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.thirdparty.plugin;
9
10 import com.google.common.collect.ImmutableList;
11 import org.eclipse.jdt.annotation.Nullable;
12 import org.opendaylight.yangtools.yang.common.Empty;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaNodeDefaults;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SchemaPathSupport;
20
21 final class ThirdPartyExtensionEffectiveStatementImpl
22         extends UnknownEffectiveStatementBase<String, ThirdPartyExtensionStatement>
23         implements ThirdPartyExtensionEffectiveStatement {
24
25     private final @Nullable SchemaPath path;
26     private final String valueFromNamespace;
27
28     ThirdPartyExtensionEffectiveStatementImpl(final Current<String, ThirdPartyExtensionStatement> stmt,
29             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
30         super(stmt, substatements);
31         path = SchemaPathSupport.toOptionalPath(stmt.getEffectiveParent().getSchemaPath().createChild(getNodeType()));
32         valueFromNamespace = stmt.getFromNamespace(ThirdPartyNamespace.class, Empty.getInstance());
33     }
34
35     @Override
36     public String getValueFromNamespace() {
37         return valueFromNamespace;
38     }
39
40     @Override
41     public QName getQName() {
42         return getNodeType();
43     }
44
45     @Override
46     @Deprecated
47     public SchemaPath getPath() {
48         return SchemaNodeDefaults.throwUnsupportedIfNull(this, path);
49     }
50
51     @Override
52     public ThirdPartyExtensionEffectiveStatement asEffectiveStatement() {
53         return this;
54     }
55 }