Eliminate SourceException throws declarations
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / UnionSpecificationImpl.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 static org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.MAX;
11
12 import java.util.Collection;
13 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.UnionSpecificationEffectiveStatementImpl;
21
22 public class UnionSpecificationImpl extends AbstractDeclaredStatement<String>
23         implements TypeStatement.UnionSpecification {
24     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
25             .TYPE)
26             .add(Rfc6020Mapping.TYPE, 1, MAX)
27             .build();
28
29     protected UnionSpecificationImpl(
30             StmtContext<String, TypeStatement.UnionSpecification, ?> context) {
31         super(context);
32     }
33
34     public static class Definition extends AbstractStatementSupport<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> {
35
36         public Definition() {
37             super(Rfc6020Mapping.TYPE);
38         }
39
40         @Override
41         public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
42             return value;
43         }
44
45         @Override
46         public TypeStatement.UnionSpecification createDeclared(
47                 StmtContext<String, TypeStatement.UnionSpecification, ?> ctx) {
48             return new UnionSpecificationImpl(ctx);
49         }
50
51         @Override
52         public EffectiveStatement<String, TypeStatement.UnionSpecification> createEffective(
53                 StmtContext<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> ctx) {
54             return new UnionSpecificationEffectiveStatementImpl(ctx);
55         }
56
57         @Override
58         public void onFullDefinitionDeclared(StmtContext.Mutable<String, UnionSpecification, EffectiveStatement<String, UnionSpecification>> stmt) {
59             super.onFullDefinitionDeclared(stmt);
60             SUBSTATEMENT_VALIDATOR.validate(stmt);
61         }
62     }
63
64     @Override
65     public String getName() {
66         return argument();
67     }
68
69     @Override
70     public Collection<? extends TypeStatement> getTypes() {
71         return allDeclared(TypeStatement.class);
72     }
73
74 }