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.EnumStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.EnumSpecificationEffectiveStatementImpl;
24 public class EnumSpecificationImpl extends AbstractDeclaredStatement<String> implements TypeStatement.EnumSpecification {
25 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
27 .add(Rfc6020Mapping.ENUM, 1, MAX)
30 protected EnumSpecificationImpl(StmtContext<String, TypeStatement.EnumSpecification, ?> context) {
34 public static class Definition
36 AbstractStatementSupport<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> {
39 super(Rfc6020Mapping.TYPE);
43 public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
48 public TypeStatement.EnumSpecification createDeclared(
49 StmtContext<String, TypeStatement.EnumSpecification, ?> ctx) {
50 return new EnumSpecificationImpl(ctx);
54 public EffectiveStatement<String, TypeStatement.EnumSpecification> createEffective(
55 StmtContext<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> ctx) {
56 return new EnumSpecificationEffectiveStatementImpl(ctx);
60 public void onFullDefinitionDeclared(StmtContext.Mutable<String, EnumSpecification,
61 EffectiveStatement<String, EnumSpecification>> stmt) throws SourceException {
62 super.onFullDefinitionDeclared(stmt);
63 SUBSTATEMENT_VALIDATOR.validate(stmt);
68 public String getName() {
73 public Collection<? extends EnumStatement> getEnums() {
74 return allDeclared(EnumStatement.class);