Add basic support for lenient path expression parsing
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / PathExpression.java
index a875ed0985265144f85ec4ad5471d11063dae458..fef07e744dc8efede4cf45a38d2e5005855fdbbb 100644 (file)
@@ -21,6 +21,19 @@ 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#CHILD} and {@link YangXPathAxis#PARENT} axis</li>
+ * <li>all steps along {@link YangXPathAxis#CHILD} 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>
+ * <li>all qualified node identifiers must me resolved</li>
+ * </ul>
+ *
  * @author Robert Varga
  */
 @Beta
@@ -35,41 +48,20 @@ public interface PathExpression extends Immutable {
     String getOriginalString();
 
     /**
-     * Returns <code>true</code> if the XPapth starts in root of YANG model, otherwise returns <code>false</code>.
+     * Return the {@link YangLocationPath} of this expression.
      *
-     * @return <code>true</code> if the XPapth starts in root of YANG model, otherwise returns <code>false</code>
+     * @return The location path
+     * @throws UnsupportedOperationException if the implementation has not parsed the string. Implementations are
+     *         strongly encouraged to perform proper parsing.
      */
-    boolean isAbsolute();
+    YangLocationPath getLocation();
 
     /**
-     * XPath-aware extension of PathExpression. Additionally to exposing {@link #getOriginalString()}, implementations
-     * of this interface expose a parsed {@link YangLocationPath}.
+     * Returns <code>true</code> if the XPapth starts in root of YANG model, otherwise returns <code>false</code>.
      *
-     * <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#CHILD} and {@link YangXPathAxis#PARENT} axis</li>
-     * <li>all steps along {@link YangXPathAxis#CHILD} 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>
-     * <li>all qualified node identifiers must me resolved</li>
-     * </ul>
+     * @return <code>true</code> if the XPapth starts in root of YANG model, otherwise returns <code>false</code>
      */
-    // FIXME: 4.0.0: this is a transitional interface and needs to be integrated directly in PathExpression
-    interface WithLocation extends PathExpression {
-        /**
-         * Return the {@link YangLocationPath} of this expression.
-         *
-         * @return The location path
-         */
-        YangLocationPath getLocation();
-
-        @Override
-        default boolean isAbsolute() {
-            return getLocation().isAbsolute();
-        }
+    default boolean isAbsolute() {
+        return getLocation().isAbsolute();
     }
 }