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.rfc7950.stmt.extension;
10 import com.google.common.collect.ImmutableList;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
14 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
17 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 final class UnrecognizedEffectiveStatementImpl extends UnknownEffectiveStatementBase<String, UnrecognizedStatement>
27 implements UnrecognizedEffectiveStatement {
28 private static final Logger LOG = LoggerFactory.getLogger(UnrecognizedEffectiveStatementImpl.class);
30 private final QName maybeQNameArgument;
31 private final @NonNull SchemaPath path;
33 UnrecognizedEffectiveStatementImpl(final Current<String, UnrecognizedStatement> stmt,
34 final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
35 super(stmt, substatements);
37 // FIXME: Remove following section after fixing 4380
38 final UnknownSchemaNode original = (UnknownSchemaNode) stmt.original();
39 if (original != null) {
40 this.maybeQNameArgument = original.getQName();
42 QName maybeQNameArgumentInit = null;
44 maybeQNameArgumentInit = StmtContextUtils.qnameFromArgument(stmt.caerbannog(), argument());
45 } catch (SourceException e) {
46 LOG.debug("Not constructing QName from {}", argument(), e);
47 maybeQNameArgumentInit = getNodeType();
49 this.maybeQNameArgument = maybeQNameArgumentInit;
54 maybePath = stmt.getEffectiveParent().schemaPath()
55 .map(parentPath -> parentPath.createChild(maybeQNameArgument)).orElse(null);
56 } catch (IllegalArgumentException | SourceException e) {
57 LOG.debug("Cannot construct path for {}, attempting to recover", stmt, e);
64 public QName getQName() {
65 return maybeQNameArgument;
70 public SchemaPath getPath() {
75 public StatementDefinition statementDefinition() {
76 return getDeclared().statementDefinition();