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;
10 import static org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.MAX;
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.spi.source.SourceException;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.UnionSpecificationEffectiveStatementImpl;
23 public class UnionSpecificationImpl extends AbstractDeclaredStatement<String>
24 implements TypeStatement.UnionSpecification {
25 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
27 .add(Rfc6020Mapping.TYPE, 1, MAX)
30 protected UnionSpecificationImpl(
31 StmtContext<String, TypeStatement.UnionSpecification, ?> context) {
35 public static class Definition extends AbstractStatementSupport<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> {
38 super(Rfc6020Mapping.TYPE);
42 public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
43 throws SourceException {
48 public TypeStatement.UnionSpecification createDeclared(
49 StmtContext<String, TypeStatement.UnionSpecification, ?> ctx) {
50 return new UnionSpecificationImpl(ctx);
54 public EffectiveStatement<String, TypeStatement.UnionSpecification> createEffective(
55 StmtContext<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> ctx) {
56 return new UnionSpecificationEffectiveStatementImpl(ctx);
60 public void onFullDefinitionDeclared(StmtContext.Mutable<String, UnionSpecification, EffectiveStatement<String, UnionSpecification>> stmt) throws SourceException {
61 super.onFullDefinitionDeclared(stmt);
62 SUBSTATEMENT_VALIDATOR.validate(stmt);
67 public String getName() {
72 public Collection<? extends TypeStatement> getTypes() {
73 return allDeclared(TypeStatement.class);