BUG-7052: Move qnameFromArgument to StmtContextUtils
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / YangValidationBundles.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.common.YangVersion.VERSION_1;
11 import static org.opendaylight.yangtools.yang.common.YangVersion.VERSION_1_1;
12
13 import com.google.common.collect.ImmutableMap;
14 import com.google.common.collect.ImmutableMap.Builder;
15 import com.google.common.collect.ImmutableSet;
16 import com.google.common.collect.ImmutableTable;
17 import com.google.common.collect.Table;
18 import java.util.Map;
19 import java.util.Set;
20 import org.opendaylight.yangtools.yang.common.YangVersion;
21 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
22 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
23
24 public final class YangValidationBundles {
25     private YangValidationBundles() {
26         throw new UnsupportedOperationException("Utility class");
27     }
28
29     public static final Set<StatementDefinition> SUPPORTED_REFINE_SUBSTATEMENTS = ImmutableSet.of(
30         YangStmtMapping.DEFAULT, YangStmtMapping.DESCRIPTION, YangStmtMapping.REFERENCE, YangStmtMapping.CONFIG,
31         YangStmtMapping.MANDATORY, YangStmtMapping.MUST, YangStmtMapping.PRESENCE, YangStmtMapping.MIN_ELEMENTS,
32         YangStmtMapping.MAX_ELEMENTS, YangStmtMapping.IF_FEATURE);
33
34     public static final Map<StatementDefinition, Set<StatementDefinition>> SUPPORTED_REFINE_TARGETS;
35     static {
36         final Builder<StatementDefinition, Set<StatementDefinition>> b = ImmutableMap.builder();
37         b.put(YangStmtMapping.DEFAULT, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.CHOICE));
38         b.put(YangStmtMapping.MANDATORY, ImmutableSet.of(
39                 YangStmtMapping.LEAF, YangStmtMapping.CHOICE, YangStmtMapping.ANYXML, YangStmtMapping.ANYDATA));
40         b.put(YangStmtMapping.PRESENCE, ImmutableSet.of(YangStmtMapping.CONTAINER));
41         b.put(YangStmtMapping.MUST, ImmutableSet.of(
42                 YangStmtMapping.CONTAINER, YangStmtMapping.LIST, YangStmtMapping.LEAF,
43                 YangStmtMapping.LEAF_LIST, YangStmtMapping.ANYXML, YangStmtMapping.ANYDATA));
44         b.put(YangStmtMapping.MIN_ELEMENTS, ImmutableSet.of(
45                 YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST));
46         b.put(YangStmtMapping.MAX_ELEMENTS, ImmutableSet.of(
47                 YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST));
48         SUPPORTED_REFINE_TARGETS = b.build();
49     }
50
51     /**
52      * Supported deviation target statements for specific deviate substatements in specific yang-version.
53      * Example: deviate 'add' adds a 'default' substatement. In YANG 1.0, the target node of such deviation can be
54      * only a leaf or a choice statement. IN YANG 1.1, the target node of such deviation can be a leaf, a leaf-list or
55      * a choice.
56      */
57     public static final Table<YangVersion, StatementDefinition, Set<StatementDefinition>> SUPPORTED_DEVIATION_TARGETS;
58     static {
59         final ImmutableTable.Builder<YangVersion, StatementDefinition, Set<StatementDefinition>> b =
60                 ImmutableTable.builder();
61         b.put(VERSION_1, YangStmtMapping.CONFIG, ImmutableSet.of(YangStmtMapping.CONTAINER, YangStmtMapping.LEAF,
62                 YangStmtMapping.LEAF_LIST, YangStmtMapping.LIST, YangStmtMapping.CHOICE, YangStmtMapping.ANYDATA,
63                 YangStmtMapping.ANYXML));
64         b.put(VERSION_1, YangStmtMapping.DEFAULT, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.CHOICE));
65         b.put(VERSION_1_1, YangStmtMapping.DEFAULT, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.LEAF_LIST,
66                 YangStmtMapping.CHOICE));
67         b.put(VERSION_1, YangStmtMapping.MANDATORY, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.CHOICE,
68                 YangStmtMapping.ANYDATA, YangStmtMapping.ANYXML));
69         b.put(VERSION_1, YangStmtMapping.MAX_ELEMENTS, ImmutableSet.of(YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST));
70         b.put(VERSION_1, YangStmtMapping.MIN_ELEMENTS, ImmutableSet.of(YangStmtMapping.LIST, YangStmtMapping.LEAF_LIST));
71         b.put(VERSION_1, YangStmtMapping.MUST, ImmutableSet.of(YangStmtMapping.CONTAINER, YangStmtMapping.LEAF,
72                 YangStmtMapping.LEAF_LIST, YangStmtMapping.LIST, YangStmtMapping.ANYXML));
73         b.put(VERSION_1_1, YangStmtMapping.MUST, ImmutableSet.of(YangStmtMapping.CONTAINER, YangStmtMapping.LEAF,
74                 YangStmtMapping.LEAF_LIST, YangStmtMapping.LIST, YangStmtMapping.ANYDATA, YangStmtMapping.ANYXML,
75                 YangStmtMapping.INPUT, YangStmtMapping.OUTPUT, YangStmtMapping.NOTIFICATION));
76         b.put(VERSION_1, YangStmtMapping.TYPE, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.LEAF_LIST));
77         b.put(VERSION_1, YangStmtMapping.UNIQUE, ImmutableSet.of(YangStmtMapping.LIST));
78         b.put(VERSION_1, YangStmtMapping.UNITS, ImmutableSet.of(YangStmtMapping.LEAF, YangStmtMapping.LEAF_LIST));
79
80         SUPPORTED_DEVIATION_TARGETS = b.build();
81     }
82
83     public static final Set<StatementDefinition> SUPPORTED_AUGMENT_TARGETS = ImmutableSet.of(
84         YangStmtMapping.CONTAINER, YangStmtMapping.LIST, YangStmtMapping.CASE, YangStmtMapping.INPUT, YangStmtMapping.OUTPUT,
85         YangStmtMapping.NOTIFICATION, YangStmtMapping.CHOICE, YangStmtMapping.RPC);
86
87     public static final Set<StatementDefinition> SUPPORTED_CASE_SHORTHANDS = ImmutableSet.of(
88         YangStmtMapping.CONTAINER, YangStmtMapping.LIST, YangStmtMapping.LEAF, YangStmtMapping.LEAF_LIST,
89         YangStmtMapping.ANYXML, YangStmtMapping.ANYDATA);
90
91     public static final Set<StatementDefinition> SUPPORTED_DATA_NODES = ImmutableSet.of(
92         YangStmtMapping.CONTAINER, YangStmtMapping.LIST, YangStmtMapping.LEAF, YangStmtMapping.LEAF_LIST,
93         YangStmtMapping.ANYXML, YangStmtMapping.ANYDATA);
94 }