BUG-865: make EnumPair getQName/getSchemaPath unimplemented
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / type / EnumEffectiveStatementImpl.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type;
9
10 import java.util.Collections;
11 import java.util.List;
12 import org.opendaylight.yangtools.yang.model.api.Status;
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.model.api.type.EnumTypeDefinition.EnumPair;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DescriptionEffectiveStatementImpl;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ReferenceEffectiveStatementImpl;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ValueEffectiveStatementImpl;
23
24 public class EnumEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, EnumStatement> implements EnumPair {
25     private final String name;
26     private String description;
27     private String reference;
28     private Status status = Status.CURRENT;
29     private Integer value;
30
31     public EnumEffectiveStatementImpl(final StmtContext<String, EnumStatement, ?> ctx) {
32         super(ctx);
33
34         name = ctx.rawStatementArgument();
35
36         for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
37             if (effectiveStatement instanceof DescriptionEffectiveStatementImpl) {
38                 description = ((DescriptionEffectiveStatementImpl) effectiveStatement).argument();
39             }
40             if (effectiveStatement instanceof ReferenceEffectiveStatementImpl) {
41                 reference = ((ReferenceEffectiveStatementImpl) effectiveStatement).argument();
42             }
43             if (effectiveStatement instanceof StatusEffectiveStatementImpl) {
44                 status = ((StatusEffectiveStatementImpl) effectiveStatement).argument();
45             }
46             if (effectiveStatement instanceof ValueEffectiveStatementImpl) {
47                 value = ((ValueEffectiveStatementImpl) effectiveStatement).argument();
48             }
49         }
50     }
51
52     @Override
53     public String getName() {
54         return name;
55     }
56
57     @Override
58     public Integer getValue() {
59         return value;
60     }
61
62     @Override
63     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
64         return Collections.emptyList();
65     }
66
67     @Override
68     public String getDescription() {
69         return description;
70     }
71
72     @Override
73     public String getReference() {
74         return reference;
75     }
76
77     @Override
78     public Status getStatus() {
79         return status;
80     }
81 }