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.StmtContext;
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 @NonNull UnrecognizedStatement declared,
34 final @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
35 final StmtContext<String, UnrecognizedStatement, ?> ctx) {
36 super(ctx.getStatementArgument(), declared, substatements, ctx);
38 // FIXME: Remove following section after fixing 4380
39 final UnknownSchemaNode original = (UnknownSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective)
41 if (original != null) {
42 this.maybeQNameArgument = original.getQName();
44 QName maybeQNameArgumentInit = null;
46 maybeQNameArgumentInit = StmtContextUtils.qnameFromArgument(ctx, argument());
47 } catch (SourceException e) {
48 LOG.debug("Not constructing QName from {}", argument(), e);
49 maybeQNameArgumentInit = getNodeType();
51 this.maybeQNameArgument = maybeQNameArgumentInit;
56 maybePath = ctx.coerceParentContext().getSchemaPath()
57 .map(parentPath -> parentPath.createChild(maybeQNameArgument)).orElse(null);
58 } catch (IllegalArgumentException | SourceException e) {
59 LOG.debug("Cannot construct path for {}, attempting to recover", ctx, e);
66 public QName getQName() {
67 return maybeQNameArgument;
72 public SchemaPath getPath() {
77 public StatementDefinition statementDefinition() {
78 return getDeclared().statementDefinition();