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 org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
17 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ValueEffectiveStatementImpl;
20 public class EnumEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<String, EnumStatement> {
21 private final List<UnknownSchemaNode> unknownSchemaNodes;
22 private final String name;
23 private final Integer declaredValue;
25 public EnumEffectiveStatementImpl(final StmtContext<String, EnumStatement, ?> ctx) {
28 name = ctx.rawStatementArgument();
30 final List<UnknownSchemaNode> unknownSchemaNodesInit = new ArrayList<>();
31 Integer declaredValueInit = null;
32 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
33 if (effectiveStatement instanceof ValueEffectiveStatementImpl) {
34 declaredValueInit = ((ValueEffectiveStatementImpl) effectiveStatement).argument();
36 if (effectiveStatement instanceof UnknownSchemaNode) {
37 unknownSchemaNodesInit.add((UnknownSchemaNode) effectiveStatement);
41 declaredValue = declaredValueInit;
42 unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodesInit);
45 public String getName() {
49 public Integer getDeclaredValue() {
54 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
55 return unknownSchemaNodes;