Create all effective statements path Nullable
[yangtools.git] / yang / odlext-parser-support / src / main / java / org / opendaylight / yangtools / odlext / parser / AnyxmlSchemaLocationEffectiveStatementImpl.java
1 /*
2  * Copyright (c) 2015 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.odlext.parser;
9
10 import com.google.common.annotations.VisibleForTesting;
11 import com.google.common.collect.ImmutableList;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.odlext.model.api.AnyxmlSchemaLocationEffectiveStatement;
14 import org.opendaylight.yangtools.odlext.model.api.AnyxmlSchemaLocationStatement;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.SchemaNodeDefaults;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.SchemaPathSupport;
23
24 @VisibleForTesting
25 public final class AnyxmlSchemaLocationEffectiveStatementImpl
26         extends UnknownEffectiveStatementBase<SchemaNodeIdentifier, AnyxmlSchemaLocationStatement>
27         implements AnyxmlSchemaLocationEffectiveStatement {
28     private final @Nullable SchemaPath path;
29
30     AnyxmlSchemaLocationEffectiveStatementImpl(
31             final Current<SchemaNodeIdentifier, AnyxmlSchemaLocationStatement> stmt,
32             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
33         super(stmt, substatements);
34         path = SchemaPathSupport.wrap(stmt.getEffectiveParent().getSchemaPath().createChild(getNodeType()));
35     }
36
37     @Override
38     public QName getQName() {
39         return getNodeType();
40     }
41
42     @Override
43     @Deprecated
44     public SchemaPath getPath() {
45         return SchemaNodeDefaults.throwUnsupportedIfNull(this, path);
46     }
47 }