30ff823413ca3ed5c1f7ee0d0c5516b05aabc589
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / ImportStatementRfc7950Support.java
1 /*
2  * Copyright (c) 2016 Inocybe Technologies 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.rfc7950;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
12 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
13 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.ImportStatementDefinition;
14 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.SupportedExtensionsMapping;
15
16 /**
17  * Implementation of import statement definition for Yang 1.1 (RFC 7950) to
18  * allow import statement to have "description" and "reference" as substatements.
19  */
20 @Beta
21 public class ImportStatementRfc7950Support extends ImportStatementDefinition {
22
23     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator
24             .builder(YangStmtMapping.IMPORT)
25             .addMandatory(YangStmtMapping.PREFIX)
26             .addOptional(YangStmtMapping.REVISION_DATE)
27             .addOptional(SupportedExtensionsMapping.SEMANTIC_VERSION)
28             .addOptional(YangStmtMapping.DESCRIPTION)
29             .addOptional(YangStmtMapping.REFERENCE)
30             .build();
31
32     @Override
33     protected SubstatementValidator getSubstatementValidator() {
34         return SUBSTATEMENT_VALIDATOR;
35     }
36 }