Bug 2366 - Effective statments impl merge, retest & bugfix
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / EnumSpecificationImpl.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;
9
10 import java.util.Collection;
11
12 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.EnumSpecificationEffectiveStatementImpl;
21
22 public class EnumSpecificationImpl extends AbstractDeclaredStatement<String> implements TypeStatement.EnumSpecification {
23
24     protected EnumSpecificationImpl(StmtContext<String, TypeStatement.EnumSpecification, ?> context) {
25         super(context);
26     }
27
28     public static class Definition
29             extends
30             AbstractStatementSupport<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> {
31
32         public Definition() {
33             super(Rfc6020Mapping.TYPE);
34         }
35
36         @Override
37         public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
38             return value;
39         }
40
41         @Override
42         public TypeStatement.EnumSpecification createDeclared(
43                 StmtContext<String, TypeStatement.EnumSpecification, ?> ctx) {
44             return new EnumSpecificationImpl(ctx);
45         }
46
47         @Override
48         public EffectiveStatement<String, TypeStatement.EnumSpecification> createEffective(
49                 StmtContext<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> ctx) {
50             return new EnumSpecificationEffectiveStatementImpl(ctx);
51         }
52     }
53
54     @Override
55     public String getName() {
56         return argument();
57     }
58
59     @Override
60     public Collection<? extends EnumStatement> getEnums() {
61         return allDeclared(EnumStatement.class);
62     }
63
64 }