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 com.google.common.collect.ImmutableList;
11 import java.util.LinkedList;
12 import java.util.List;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
24 public class FeatureEffectiveStatementImpl extends EffectiveStatementBase<QName, FeatureStatement> implements
28 private SchemaPath path;
29 private List<UnknownSchemaNode> unknownSchemaNodes;
30 private String description;
31 private String reference;
32 private Status status;
34 public FeatureEffectiveStatementImpl(StmtContext<QName, FeatureStatement, ?> ctx) {
37 this.qName = ctx.getStatementArgument();
38 this.path = Utils.getSchemaPath(ctx);
43 private void initFields() {
45 List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
47 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
48 if (effectiveStatement instanceof DescriptionEffectiveStatementImpl) {
49 description = ((DescriptionEffectiveStatementImpl) effectiveStatement).argument();
51 if (effectiveStatement instanceof ReferenceEffectiveStatementImpl) {
52 reference = ((ReferenceEffectiveStatementImpl) effectiveStatement).argument();
54 if (effectiveStatement instanceof StatusEffectiveStatementImpl) {
55 status = ((StatusEffectiveStatementImpl) effectiveStatement).argument();
58 if (effectiveStatement instanceof UnknownSchemaNode) {
59 unknownNodesInit.add((UnknownSchemaNode) effectiveStatement);
63 this.unknownSchemaNodes = ImmutableList.copyOf(unknownNodesInit);
67 public QName getQName() {
72 public SchemaPath getPath() {
77 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
78 return unknownSchemaNodes;
82 public String getDescription() {
87 public String getReference() {
92 public Status getStatus() {
97 public int hashCode() {
100 result = prime * result + Objects.hashCode(qName);
101 result = prime * result + Objects.hashCode(path);
106 public boolean equals(final Object obj) {
113 if (getClass() != obj.getClass()) {
116 FeatureEffectiveStatementImpl other = (FeatureEffectiveStatementImpl) obj;
118 if (other.qName != null) {
121 } else if (!qName.equals(other.qName)) {
125 if (other.path != null) {
128 } else if (!path.equals(other.path)) {
135 public String toString() {
136 StringBuilder sb = new StringBuilder(FeatureEffectiveStatementImpl.class.getSimpleName());
137 sb.append("[name=").append(qName).append("]");
138 return sb.toString();