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.stmt.rfc6020.effective;
10 import java.util.LinkedList;
11 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
23 import com.google.common.collect.ImmutableList;
25 public class FeatureEffectiveStatementImpl extends EffectiveStatementBase<QName, FeatureStatement> implements
29 private SchemaPath path;
30 private List<UnknownSchemaNode> unknownSchemaNodes;
31 private String description;
32 private String reference;
33 private Status status;
35 public FeatureEffectiveStatementImpl(StmtContext<QName, FeatureStatement, ?> ctx) {
38 this.qName = ctx.getStatementArgument();
39 this.path = Utils.getSchemaPath(ctx);
44 private void initFields() {
46 List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
48 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
49 if (effectiveStatement instanceof DescriptionEffectiveStatementImpl) {
50 description = ((DescriptionEffectiveStatementImpl) effectiveStatement).argument();
52 if (effectiveStatement instanceof ReferenceEffectiveStatementImpl) {
53 reference = ((ReferenceEffectiveStatementImpl) effectiveStatement).argument();
55 if (effectiveStatement instanceof StatusEffectiveStatementImpl) {
56 status = ((StatusEffectiveStatementImpl) effectiveStatement).argument();
59 if (effectiveStatement instanceof UnknownSchemaNode) {
60 unknownNodesInit.add((UnknownSchemaNode) effectiveStatement);
64 this.unknownSchemaNodes = ImmutableList.copyOf(unknownNodesInit);
68 public QName getQName() {
73 public SchemaPath getPath() {
78 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
79 return unknownSchemaNodes;
83 public String getDescription() {
88 public String getReference() {
93 public Status getStatus() {
98 public int hashCode() {
101 result = prime * result + ((qName == null) ? 0 : qName.hashCode());
102 result = prime * result + ((path == null) ? 0 : path.hashCode());
107 public boolean equals(final Object obj) {
114 if (getClass() != obj.getClass()) {
117 FeatureEffectiveStatementImpl other = (FeatureEffectiveStatementImpl) obj;
119 if (other.qName != null) {
122 } else if (!qName.equals(other.qName)) {
126 if (other.path != null) {
129 } else if (!path.equals(other.path)) {
136 public String toString() {
137 StringBuilder sb = new StringBuilder(FeatureEffectiveStatementImpl.class.getSimpleName());
138 sb.append("[name=").append(qName).append("]");
139 return sb.toString();