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.type;
10 import com.google.common.collect.ImmutableList;
11 import java.util.ArrayList;
12 import java.util.List;
13 import javax.annotation.Nonnull;
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.stmt.EnumEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ValueEffectiveStatementImpl;
22 public class EnumEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<String, EnumStatement>
23 implements EnumEffectiveStatement {
24 private final List<UnknownSchemaNode> unknownSchemaNodes;
25 private final String name;
26 private final Integer declaredValue;
28 public EnumEffectiveStatementImpl(final StmtContext<String, EnumStatement, ?> ctx) {
31 name = ctx.rawStatementArgument();
33 final List<UnknownSchemaNode> unknownSchemaNodesInit = new ArrayList<>();
34 Integer declaredValueInit = null;
35 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
36 if (effectiveStatement instanceof ValueEffectiveStatementImpl) {
37 declaredValueInit = ((ValueEffectiveStatementImpl) effectiveStatement).argument();
39 if (effectiveStatement instanceof UnknownSchemaNode) {
40 unknownSchemaNodesInit.add((UnknownSchemaNode) effectiveStatement);
44 declaredValue = declaredValueInit;
45 unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodesInit);
48 public String getName() {
52 public Integer getDeclaredValue() {
58 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
59 return unknownSchemaNodes;