Define PathExpression is a separate concept 22/81022/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Mar 2019 09:17:00 +0000 (10:17 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Mar 2019 10:30:21 +0000 (11:30 +0100)
RevisionAwareXPath is not what leafref types are referencing, define
PathExpression which captures the proper semantic concept, which
is based on YangLocationPath.

JIRA: YANGTOOLS-969
Change-Id: I1f4a670d13a39ca60cda4771bb7ff46a90449bfe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
features/odl-yangtools-parser-api/pom.xml
yang/yang-model-api/pom.xml
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/PathExpression.java [new file with mode: 0644]

index 248b27fd4bf68251cd7eeba9e7f622346faa3c16..9534f7bfce52db37e0d72f44feab1f375786e209 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>odl-yangtools-xpath-api</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>odlext-model-api</artifactId>
index e069469cd4c3e2eb4e3a9116a77006f8efa2f2f5..3764225ce68089dcabeff4e8155d0840efe509a1 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-xpath-api</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/PathExpression.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/PathExpression.java
new file mode 100644 (file)
index 0000000..f3a251a
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.xpath.api.YangBinaryOperator;
+import org.opendaylight.yangtools.yang.xpath.api.YangFunction;
+import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath;
+import org.opendaylight.yangtools.yang.xpath.api.YangLocationPath.QNameStep;
+import org.opendaylight.yangtools.yang.xpath.api.YangXPathAxis;
+import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression;
+
+/**
+ * An expression as defined in <a href="https://tools.ietf.org/html/rfc7950#section-9.9.2">RFC7950 Section 9.9.2</a>,
+ * i.e. the argument of a {@code path} statement.
+ *
+ * <p>
+ * Semantically a {@link PathExpression} is similar to a {@link YangXPathExpression} with guarantees around what
+ * subexpressions it can contain:
+ * <ul>
+ * <li>the root expression must be a {@link YangLocationPath}</li>
+ * <li>it can contain steps only along {@link YangXPathAxis#DESCENDANT} and {@link YangXPathAxis#PARENT} axis</li>
+ * <li>all steps along {@link YangXPathAxis#DESCENDANT} axis are {@link QNameStep}</li>
+ * <li>the only function invocation is {@link YangFunction#CURRENT}</li>
+ * <li>only {@link YangBinaryOperator#EQUALS} is allowed</li>
+ * <li>no literals nor numbers are allowed</li>
+ * </ul>
+ *
+ * @author Robert Varga
+ */
+@Beta
+public interface PathExpression extends Immutable {
+    /**
+     * Return the {@link YangLocationPath} of this expression.
+     *
+     * @return The location path
+     */
+    @NonNull YangLocationPath getLocation();
+}