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 java.util.Objects;
11 import javax.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.stmt.UnrecognizedEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
17 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
21 final class UnrecognizedEffectiveStatementImpl extends UnknownEffectiveStatementBase<String, UnrecognizedStatement>
22 implements UnrecognizedEffectiveStatement {
24 private final QName maybeQNameArgument;
25 private final SchemaPath path;
27 UnrecognizedEffectiveStatementImpl(final StmtContext<String, UnrecognizedStatement, ?> ctx) {
30 // FIXME: Remove following section after fixing 4380
31 final UnknownSchemaNode original = (UnknownSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective)
33 if (original != null) {
34 this.maybeQNameArgument = original.getQName();
36 QName maybeQNameArgumentInit = null;
38 maybeQNameArgumentInit = StmtContextUtils.qnameFromArgument(ctx, argument());
39 } catch (IllegalArgumentException e) {
40 maybeQNameArgumentInit = getNodeType();
42 this.maybeQNameArgument = maybeQNameArgumentInit;
44 path = ctx.getParentContext().getSchemaPath().get().createChild(maybeQNameArgument);
49 public QName getQName() {
50 return maybeQNameArgument;
55 public SchemaPath getPath() {
60 public int hashCode() {
63 result = prime * result + Objects.hashCode(maybeQNameArgument);
64 result = prime * result + Objects.hashCode(path);
65 result = prime * result + Objects.hashCode(getNodeType());
66 result = prime * result + Objects.hashCode(getNodeParameter());
71 public boolean equals(final Object obj) {
75 if (!(obj instanceof UnrecognizedEffectiveStatementImpl)) {
78 UnrecognizedEffectiveStatementImpl other = (UnrecognizedEffectiveStatementImpl) obj;
79 return Objects.equals(maybeQNameArgument, other.maybeQNameArgument) && Objects.equals(path, other.path)
80 && Objects.equals(getNodeType(), other.getNodeType())
81 && Objects.equals(getNodeParameter(), other.getNodeParameter());