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 org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
13 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
16 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
19 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 final class UnrecognizedEffectiveStatementImpl extends UnknownEffectiveStatementBase<String, UnrecognizedStatement>
24 implements UnrecognizedEffectiveStatement {
25 private static final Logger LOG = LoggerFactory.getLogger(UnrecognizedEffectiveStatementImpl.class);
27 private final QName maybeQNameArgument;
28 private final @NonNull SchemaPath path;
30 UnrecognizedEffectiveStatementImpl(final StmtContext<String, UnrecognizedStatement, ?> ctx) {
33 // FIXME: Remove following section after fixing 4380
34 final UnknownSchemaNode original = (UnknownSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective)
36 if (original != null) {
37 this.maybeQNameArgument = original.getQName();
39 QName maybeQNameArgumentInit = null;
41 maybeQNameArgumentInit = StmtContextUtils.qnameFromArgument(ctx, argument());
42 } catch (SourceException e) {
43 LOG.debug("Not constructing QName from {}", argument(), e);
44 maybeQNameArgumentInit = getNodeType();
46 this.maybeQNameArgument = maybeQNameArgumentInit;
51 maybePath = ctx.coerceParentContext().getSchemaPath()
52 .map(parentPath -> parentPath.createChild(maybeQNameArgument)).orElse(null);
53 } catch (IllegalArgumentException | SourceException e) {
54 LOG.debug("Cannot construct path for {}, attempting to recover", ctx, e);
61 public QName getQName() {
62 return maybeQNameArgument;
66 public SchemaPath getPath() {