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.EnumStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDocumentedNode;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ValueEffectiveStatementImpl;
21 public class EnumEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<String, EnumStatement> {
22 private final List<UnknownSchemaNode> unknownSchemaNodes;
23 private final String name;
24 private final Integer declaredValue;
26 public EnumEffectiveStatementImpl(final StmtContext<String, EnumStatement, ?> ctx) {
29 name = ctx.rawStatementArgument();
31 final List<UnknownSchemaNode> unknownSchemaNodesInit = new ArrayList<>();
32 Integer declaredValueInit = null;
33 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
34 if (effectiveStatement instanceof ValueEffectiveStatementImpl) {
35 declaredValueInit = ((ValueEffectiveStatementImpl) effectiveStatement).argument();
37 if (effectiveStatement instanceof UnknownSchemaNode) {
38 unknownSchemaNodesInit.add((UnknownSchemaNode) effectiveStatement);
42 declaredValue = declaredValueInit;
43 unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodesInit);
46 public String getName() {
50 public Integer getDeclaredValue() {
56 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
57 return unknownSchemaNodes;