Populate model/ hierarchy
[yangtools.git] / xpath / yang-xpath-api / src / main / java / org / opendaylight / yangtools / yang / xpath / api / YangFunction.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o.  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.xpath.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import org.opendaylight.yangtools.concepts.Identifiable;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.common.YangConstants;
16 import org.opendaylight.yangtools.yang.common.YangVersion;
17
18 /**
19  * Functions known to a YANG XPath.
20  *
21  * @author Robert Varga
22  */
23 @Beta
24 public enum YangFunction implements Identifiable<QName> {
25     // XPath 1.0 functions
26     BOOLEAN("boolean"),
27     CEILING("ceiling"),
28     CONCAT("concat"),
29     CONTAINS("contains"),
30     COUNT("count"),
31     FALSE("false"),
32     FLOOR("floor"),
33     ID("id"),
34     LANG("lang"),
35     LAST("last"),
36     LOCAL_NAME("local-name"),
37     NAME("name"),
38     NUMBER("number"),
39     NAMESPACE_URI("namespace-uri"),
40     NORMALIZE_SPACE("normalize-space"),
41     NOT("not"),
42     POSITION("position"),
43     ROUND("round"),
44     STARTS_WITH("starts-with"),
45     STRING("string"),
46     STRING_LENGTH("string-length"),
47     SUM("sum"),
48     SUBSTRING("substring"),
49     SUBSTRING_AFTER("substring-after"),
50     SUBSTRING_BEFORE("substring-before"),
51     TRANSLATE("translate"),
52     TRUE("true"),
53
54     // RFC6020 functions
55     CURRENT("current"),
56
57     // RFC7950 functions
58     BIT_IS_SET("bit-is-set", YangVersion.VERSION_1_1),
59     DEREF("deref", YangVersion.VERSION_1_1),
60     DERIVED_FROM("derived-from", YangVersion.VERSION_1_1),
61     DERIVED_FROM_OR_SELF("derived-from-or-self", YangVersion.VERSION_1_1),
62     ENUM_VALUE("enum-value", YangVersion.VERSION_1_1),
63     RE_MATCH("re-match", YangVersion.VERSION_1_1);
64
65     private final QName identifier;
66     private final YangVersion yangVersion;
67
68     YangFunction(final String localName, final YangVersion yangVersion) {
69         identifier = QName.create(YangConstants.RFC6020_YIN_MODULE, localName).intern();
70         this.yangVersion = requireNonNull(yangVersion);
71     }
72
73     YangFunction(final String localName) {
74         this(localName, YangVersion.VERSION_1);
75     }
76
77     @Override
78     public QName getIdentifier() {
79         return identifier;
80     }
81
82     /**
83      * Return the minimum YANG version where this function is supported.
84      *
85      * @return First YANG version where this function appeared.
86      */
87     public YangVersion getYangVersion() {
88         return yangVersion;
89     }
90 }